mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Reuse precomputed escapes for Latin-1 characters instead of joining two byte escapes on every occurrence. This reduces repeated work when querystring and URLSearchParams serialize these characters. Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com> PR-URL: https://github.com/nodejs/node/pull/66756 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
14 lines
502 B
JavaScript
14 lines
502 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('node:assert');
|
|
const querystring = require('node:querystring');
|
|
|
|
for (let codePoint = 0x80; codePoint < 0x800; codePoint++) {
|
|
const character = String.fromCharCode(codePoint);
|
|
const input = `prefix${character}${character}/suffix`;
|
|
const expected = encodeURIComponent(input);
|
|
assert.strictEqual(querystring.escape(input), expected);
|
|
assert.strictEqual(new URLSearchParams([[input, input]]).toString(), `${expected}=${expected}`);
|
|
}
|