Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const SLASH_RE = /\//g; // %2F
const EQUAL_RE = /=/g; // %3D
const IM_RE = /\?/g; // %3F
const PLUS_RE = /\+/g; // %2B
const CARET_RE = /\^/g; // %5E
const BACKTICK_RE = /`/g; // %60
const PIPE_RE = /\|/g; // %7C

const ENC_CARET_RE = /%5e/gi; // ^
const ENC_BACKTICK_RE = /%60/gi; // `
Expand Down Expand Up @@ -64,9 +67,10 @@ export function encodeQueryValue(input: QueryValue): string {
.replace(ENC_SPACE_RE, "+")
.replace(HASH_RE, "%23")
.replace(AMPERSAND_RE, "%26")
.replace(ENC_BACKTICK_RE, "`")
.replace(ENC_CARET_RE, "^")
.replace(BACKTICK_RE, "%60")
.replace(CARET_RE, "%5E")
.replace(SLASH_RE, "%2F")
.replace(PIPE_RE, "%7C")
);
}

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: String.raw`!@#$%^&*()_+{}[]|\:;<>,./?`,
out: "!@%23$%25^%26*()_%2B%7B%7D%5B%5D|%5C:;%3C%3E,.%2F?",
out: "!@%23$%25%5E%26*()_%2B%7B%7D%5B%5D%7C%5C:;%3C%3E,.%2F?",
},
];

Expand Down