Skip to content

Commit a0a81ea

Browse files
deepview-autofixclaudeChALkeR
authored andcommitted
[Fix] stringify: use configured delimiter after charsetSentinel
The `utf8=...` charset sentinel was followed by a hardcoded `&`, ignoring `options.delimiter`. With any non-`&` delimiter the output mixed delimiters (e.g. `utf8=%E2%9C%93&a=1;b=2`), breaking self round-tripping. Emit the configured delimiter instead, and add a regression test. Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com> Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com> Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
1 parent e3062f7 commit a0a81ea

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/stringify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ module.exports = function (object, opts) {
350350
if (options.charsetSentinel) {
351351
if (options.charset === 'iso-8859-1') {
352352
// encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
353-
prefix += 'utf8=%26%2310003%3B&';
353+
prefix += 'utf8=%26%2310003%3B' + options.delimiter;
354354
} else {
355355
// encodeURIComponent('✓')
356-
prefix += 'utf8=%E2%9C%93&';
356+
prefix += 'utf8=%E2%9C%93' + options.delimiter;
357357
}
358358
}
359359

test/stringify.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,12 @@ test('stringify()', function (t) {
11971197
'adds the right sentinel when instructed to and the charset is iso-8859-1'
11981198
);
11991199

1200+
st.equal(
1201+
qs.stringify({ a: 1, b: 2 }, { charsetSentinel: true, delimiter: ';' }),
1202+
'utf8=%E2%9C%93;a=1;b=2',
1203+
'uses the configured delimiter after the sentinel'
1204+
);
1205+
12001206
st.end();
12011207
});
12021208

0 commit comments

Comments
 (0)