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:
parent
449f941b7b
commit
d1c0f8f91c
2 changed files with 40 additions and 3 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue