Skip to content

Commit 0acc6af

Browse files
Alex JamshidiAlex Jamshidi
authored andcommitted
pr changes made
1 parent c698639 commit 0acc6af

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

Sprint-2/implement/contains.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ describe("contains", () => {
4949
// Then it should return false or throw an error
5050
it("given invalid parameter (an array) returns false or throws an error", () => {
5151
expect(contains([], [])).toEqual(false);
52-
expect(contains(["a", 1], "a")).toEqual(false);
52+
expect(contains(["a", 1], 1)).toEqual(false);
5353
expect(contains({ a: 1, b: 2 }, ["a"])).toEqual(false);
54-
expect(contains(["a", 1], ["a"])).toEqual(false);
5554
});
5655

5756
it("given null returns false", () => {

Sprint-2/implement/querystring.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ function parseQueryString(queryString) {
44
return queryParams;
55
}
66

7-
// Adds percentage-encoded characters
8-
queryString = decodeURIComponent(queryString);
9-
107
// Replaces + with space
118
queryString = queryString.replaceAll("+", " ");
12-
139
const keyValuePairs = queryString.split("&");
1410

1511
for (const pair of keyValuePairs) {
@@ -18,7 +14,13 @@ function parseQueryString(queryString) {
1814
if (!pair.includes("=")) {
1915
index = pair.length;
2016
}
21-
const [key, value] = [pair.slice(0, index), pair.slice(index + 1)];
17+
const rawKey = pair.slice(0, index);
18+
const rawValue = pair.slice(index + 1);
19+
20+
// Remove percentage-encoded characters
21+
const key = decodeURIComponent(rawKey);
22+
const value = decodeURIComponent(rawValue);
23+
2224
queryParams[key] = value;
2325
}
2426
}

0 commit comments

Comments
 (0)