Skip to content

Commit edb970d

Browse files
author
JorvanW
committed
removed console.log in code
1 parent fca3dde commit edb970d

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

‎Sprint-2/implement/querystring.js‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1-
21
function parseQueryString(queryString) {
32
const queryParams = {};
43
if (queryString.length === 0) {
54
return queryParams;
65
}
76
let keyValuePairs = queryString.split("&");
8-
9-
7+
108
for (const pair of keyValuePairs) {
11-
if (!pair) continue; // continue is to skip empty strings
12-
let [key,...values] = pair.split("=");
13-
14-
key = decodeURIComponent(key.replace(/\+/g, " "));
15-
const value = decodeURIComponent(values.join("=").replace(/\+/g, " "));
9+
if (!pair) continue; // continue is to skip empty strings
10+
let [key, ...values] = pair.split("=");
11+
12+
key = decodeURIComponent(key.replace(/\+/g, " "));
13+
const value = decodeURIComponent(values.join("=").replace(/\+/g, " "));
1614

17-
18-
/* decodeURIComponent function decodes percent encoded characters
15+
/* decodeURIComponent function decodes percent encoded characters
1916
"replace" swaps one character with another
2017
(/../) means the begining and end of a regex pattern (better for characters)
21-
'\+' is an escaped '+' because it has its own function in coding */
22-
23-
queryParams[key] = value;
18+
'\+' is an escaped '+' because it has its own function in coding */
2419

25-
26-
console.log(pair)
20+
queryParams[key] = value;
2721
}
2822

2923
return queryParams;
3024
}
3125

32-
3326
module.exports = parseQueryString;

0 commit comments

Comments
 (0)