Skip to content

Commit 8427bfd

Browse files
Alex JamshidiAlex Jamshidi
authored andcommitted
updated code to use decodeURIcomponent
1 parent 193230c commit 8427bfd

1 file changed

Lines changed: 1 addition & 18 deletions

File tree

Sprint-2/implement/querystring.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function parseQueryString(queryString) {
55
}
66

77
// Adds percentage-encoded characters
8-
queryString = changePEC(queryString);
8+
queryString = decodeURIComponent(queryString);
99

1010
// Replaces + with space
1111
queryString = queryString.replaceAll("+", " ");
@@ -26,21 +26,4 @@ function parseQueryString(queryString) {
2626
return queryParams;
2727
}
2828

29-
// this function below can have the object PEC expanded to include all percentage-encoded characters
30-
// currently without adding this database, an unknown PEC could cause the code to get stuck in an infinite loop
31-
32-
function changePEC(string) {
33-
const PEC = { "%24": "$", "%2F": "/" };
34-
while (string.includes("%")) {
35-
const index = string.indexOf("%");
36-
const code = string.slice(index, index + 3);
37-
if (PEC[code]) {
38-
string = string.replace(code, PEC[code]);
39-
} else {
40-
break;
41-
}
42-
}
43-
return string;
44-
}
45-
4629
module.exports = parseQueryString;

0 commit comments

Comments
 (0)