Skip to content

Commit

Permalink
[Fix] hex characters in strings should be uppercased, to match node `…
Browse files Browse the repository at this point in the history
…assert`
  • Loading branch information
ljharb committed Jul 30, 2020
1 parent ee60c03 commit 6ab8faa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions index.js
Expand Up @@ -315,10 +315,14 @@ function inspectString(str, opts) {
function lowbyte(c) {
var n = c.charCodeAt(0);
var x = {
8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r'
8: 'b',
9: 't',
10: 'n',
12: 'f',
13: 'r'
}[n];
if (x) { return '\\' + x; }
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16).toUpperCase();
}

function markBoxed(str) {
Expand Down
2 changes: 1 addition & 1 deletion test/lowbyte.js
Expand Up @@ -7,6 +7,6 @@ test('interpolate low bytes', function (t) {
t.plan(1);
t.equal(
inspect(obj),
"{ x: 'a\\r\\nb', y: '\\x05! \\x1f \\x12' }"
"{ x: 'a\\r\\nb', y: '\\x05! \\x1F \\x12' }"
);
});

0 comments on commit 6ab8faa

Please sign in to comment.