Reduce duplication when parsing searchParams in the getPdfFilenameFromUrl function#20690
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/botio unittest |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/bc723c74ccda90b/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/4f451d2be80baac/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/4f451d2be80baac/output.txt Total script time: 2.66 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/bc723c74ccda90b/output.txt Total script time: 8.99 mins
|
|
Thanks! I think both approaches make the intent clear, and this new one is shorter which can't hurt. |
Currently we essentially "duplicate" the same code for parsing the
valuesandkeysof thesearchParams, which seems a little unnecessary.To be able to parse the
searchParamsfrom 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 theArray.prototype.findLast()method instead.Please note: I completely understand if this patch is rejected, on account of being less readable than the current code.