Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
util: extend stripVTControlCharacters regression tests
Signed-off-by: dushyant <[email protected]>
  • Loading branch information
dushyant-hada-90 committed Jul 26, 2026
commit 29f6205585d71c6c50c3e621654edb33deda6580
17 changes: 17 additions & 0 deletions test/parallel/test-util-stripvtcontrolcharacters.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,26 @@ for (const ST of ['\u0007', '\u001B\u005C', '\u009C']) {
[`\u001B]8;;https://example.com/!foo${ST}label\u001B]8;;${ST}`, 'label'],
[`\u001B]8;;https://example.com/foo+bar${ST}label\u001B]8;;${ST}`, 'label'],
[`\u001B]8;;https://example.com/[foo]${ST}label\u001B]8;;${ST}`, 'label'],
[`\u001B]8;;https://example.com/foo$bar${ST}label\u001B]8;;${ST}`, 'label'],
[`\u001B]8;;https://example.com/foo'bar${ST}label\u001B]8;;${ST}`, 'label'],
[`\u001B]8;;https://example.com/foo*bar${ST}label\u001B]8;;${ST}`, 'label'],
[`\u001B]8;;https://example.com/foo,bar${ST}label\u001B]8;;${ST}`, 'label'],
);
}

// Colon-delimited CSI sub-parameters (SGR) should be stripped like the
// semicolon-delimited form.
tests.push(
['\u001B[38:2:255:0:0mHello\u001B[0m', 'Hello'],
['\u001B[4:3mUnderline\u001B[4:0m', 'Underline'],
);

// Malformed/truncated OSC sequences without any string terminator are left
// unmatched rather than being partially stripped.
tests.push(
['\u001B]8;;https://example.com/no-terminator', 'ttps://example.com/no-terminator'],
);

test('util.stripVTControlCharacters', (t) => {
for (const [before, expected] of tests) {
t.assert.strictEqual(util.stripVTControlCharacters(before), expected);
Expand Down