Skip to content

Commit 2650a02

Browse files
committed
Fix: Bug stringifying a string that contains "="
1 parent f38d5e6 commit 2650a02

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/JsonURL.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const RX_AQF_DECODE = /(![\s\S]?)/g;
4040
// DO NOT PUT //g ON THESE!!!
4141
//
4242
const RX_ENCODE_STRING_SAFE =
43-
/^[-A-Za-z0-9._~!$*;=@?/ ][-A-Za-z0-9._~!$*;=@?/' ]*$/;
44-
const RX_ENCODE_STRING_QSAFE = /^[-A-Za-z0-9._~!$*,;=@?/(): ]+$/;
43+
/^[-A-Za-z0-9._~!$*;@?/ ][-A-Za-z0-9._~!$*;@?/' ]*$/;
44+
const RX_ENCODE_STRING_QSAFE = /^[-A-Za-z0-9._~!$*,;@?/(): ]+$/;
4545
const RX_ENCODE_NUMBER = /^-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?$/;
4646

4747
const RX_ENCODE_BASE = /[(),:]|%2[04]|%3B/gi;
@@ -289,7 +289,7 @@ function toJsonURLText_String(options, depth, isKey) {
289289

290290
//
291291
// if the string needs to be encoded then it no longer looks like a
292-
// literal and does not needs to be quoted.
292+
// literal and does not need to be quoted.
293293
//
294294
return encodeURIComponent(this);
295295
}

test/parseLiteral.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ test.each([
173173
["-e+1", "-e 1", undefined, undefined],
174174
["1e%2B1", "1e+1", 10, "1e+1"],
175175
["%26true", "&true", undefined, undefined],
176+
["%3Dtrue", "=true", undefined, undefined],
176177
])("JsonURL.parseLiteral(%p)", (text, value, aqfValue, strLitValue) => {
177178
let keyValue = typeof value === "string" ? value : text;
178179
if (aqfValue === undefined) {

test/stringify.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ test.each([
9494
[",,,", "',,,'", "%2C%2C%2C", "!,!,!,"],
9595
[" ", "+++", undefined, undefined],
9696
["Bob & Frank", "Bob+%26+Frank", undefined, undefined],
97+
["Bob = Frank", "Bob+%3D+Frank", undefined, undefined],
9798
["'hello", "%27hello", "'hello", undefined],
9899
[1e5, "100000", undefined, undefined],
99100
])("JsonURL.stringify(%p)", (value, expected, expectedISL, expectedAQF) => {

0 commit comments

Comments
 (0)