Skip to content

Commit

Permalink
fix to replace some more escape chars
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkit-30 committed Dec 7, 2022
1 parent 1fc39d5 commit bbba3c7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/internal/test_runner/tap_stream.js
Expand Up @@ -131,9 +131,18 @@ class TapStream extends Readable {

// In certain places, # and \ need to be escaped as \# and \\.
function tapEscape(input) {
return StringPrototypeReplaceAll(StringPrototypeReplaceAll(
StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#'
), '\n', '\\n');
[{ escapeChar: '\\', tappedEscape: '\\\\' },
{ escapeChar: '#', tappedEscape: '\\#' },
{ escapeChar: '\n', tappedEscape: '\\n' },
{ escapeChar: '\t', tappedEscape: '\\t' },
{ escapeChar: '\r', tappedEscape: '\\r' },
{ escapeChar: '\f', tappedEscape: '\\f' },
{ escapeChar: '\b', tappedEscape: '\\b' },
{ escapeChar: '\v', tappedEscape: '\\v' },
].forEach(({ escapeChar, tappedEscape }) => {
input = StringPrototypeReplaceAll(input, escapeChar, tappedEscape);
});
return input;
}

function jsToYaml(indent, name, value) {
Expand Down

0 comments on commit bbba3c7

Please sign in to comment.