Skip to content

Reduce duplication when parsing searchParams in the getPdfFilenameFromUrl function#20690

Merged
timvandermeij merged 1 commit intomozilla:masterfrom
Snuffleupagus:getPdfFilenameFromUrl-searchParams-findLast
Feb 20, 2026
Merged

Reduce duplication when parsing searchParams in the getPdfFilenameFromUrl function#20690
timvandermeij merged 1 commit intomozilla:masterfrom
Snuffleupagus:getPdfFilenameFromUrl-searchParams-findLast

Conversation

@Snuffleupagus
Copy link
Collaborator

Currently we essentially "duplicate" the same code for parsing the values and keys of the searchParams, which seems a little unnecessary.

To be able to parse the searchParams from the end, we currently create an Array (from the Iterator) and then reverse it before finally looping through it. Here the latter two steps can be replaced with the Array.prototype.findLast() method instead.

Please note: I completely understand if this patch is rejected, on account of being less readable than the current code.

…FromUrl` function

Currently we essentially "duplicate" the same code for parsing the `values` and `keys` of the `searchParams`, which seems a little unnecessary.

To be able to parse the `searchParams` from the end, we currently create an Array (from the Iterator) and then reverse it before finally looping through it. Here the latter two steps can be replaced with the `Array.prototype.findLast()` method instead.

*Please note:* I completely understand if this patch is rejected, on account of being less readable than the current code.
@codecov-commenter
Copy link

codecov-commenter commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.64%. Comparing base (74ab1a9) to head (34f2718).
⚠️ Report is 31 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20690      +/-   ##
==========================================
- Coverage   62.66%   62.64%   -0.02%     
==========================================
  Files         169      169              
  Lines      119865   119860       -5     
==========================================
- Hits        75111    75086      -25     
- Misses      44754    44774      +20     
Flag Coverage Δ
unittestcli 62.64% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Snuffleupagus
Copy link
Collaborator Author

/botio unittest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/bc723c74ccda90b/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/4f451d2be80baac/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/4f451d2be80baac/output.txt

Total script time: 2.66 mins

  • Unit Tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/bc723c74ccda90b/output.txt

Total script time: 8.99 mins

  • Unit Tests: FAILED

@timvandermeij timvandermeij merged commit e07e8ed into mozilla:master Feb 20, 2026
12 checks passed
@timvandermeij
Copy link
Contributor

Thanks! I think both approaches make the intent clear, and this new one is shorter which can't hurt.

@Snuffleupagus Snuffleupagus deleted the getPdfFilenameFromUrl-searchParams-findLast branch February 20, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants