1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Implement unit tests for the parseQueryString utility function

Now that these unit tests are in place, we also take the opportunity to
slightly modernize the code itself by using a `for ... of` loop.
This commit is contained in:
Tim van der Meij 2021-08-01 13:54:16 +02:00
parent 449f941b7b
commit d1c0f8f91c
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
2 changed files with 40 additions and 3 deletions

View file

@ -185,10 +185,9 @@ function watchScroll(viewAreaElement, callback) {
* @returns {Map}
*/
function parseQueryString(query) {
const parts = query.split("&");
const params = new Map();
for (let i = 0, ii = parts.length; i < ii; ++i) {
const param = parts[i].split("="),
for (const part of query.split("&")) {
const param = part.split("="),
key = param[0].toLowerCase(),
value = param.length > 1 ? param[1] : "";
params.set(decodeURIComponent(key), decodeURIComponent(value));