Skip to content

Commit

Permalink
fix(encodeQueryValue): encode the slash character (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexrw authored Feb 5, 2024
1 parent dcf926e commit 47f4070
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function encodeQueryValue(input: QueryValue): string {
.replace(AMPERSAND_RE, "%26")
.replace(ENC_BACKTICK_RE, "`")
.replace(ENC_CARET_RE, "^")
.replace(SLASH_RE, "%2F")
);
}

Expand Down
2 changes: 1 addition & 1 deletion test/encoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe("encodeQueryValue", () => {
},
{
input: "!@#$%^&*()_+{}[]|\\:;<>,./?",
out: "!@%23$%25^%26*()_%2B%7B%7D%5B%5D|%5C:;%3C%3E,./?",
out: "!@%23$%25^%26*()_%2B%7B%7D%5B%5D|%5C:;%3C%3E,.%2F?",
},
];

Expand Down
4 changes: 2 additions & 2 deletions test/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe("normalizeURL", () => {
"/http:/": "/http:/",
"http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/":
"http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/",
"http://localhost/?redirect=http://google.com?q=test":
"http://localhost/?redirect=http://google.com?q=test",
"http://localhost/?redirect=http:%2F%2Fgoogle.com?q=test":
"http://localhost/?redirect=http:%2F%2Fgoogle.com?q=test",
"http://localhost/?email=some+v1@email.com":
"http://localhost/?email=some+v1@email.com",
"http://localhost/?email=some%2Bv1%40email.com":
Expand Down

0 comments on commit 47f4070

Please sign in to comment.