Skip to content

Commit 6ab8faa

Browse files
committed
[Fix] hex characters in strings should be uppercased, to match node assert
1 parent ee60c03 commit 6ab8faa

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,14 @@ function inspectString(str, opts) {
315315
function lowbyte(c) {
316316
var n = c.charCodeAt(0);
317317
var x = {
318-
8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r'
318+
8: 'b',
319+
9: 't',
320+
10: 'n',
321+
12: 'f',
322+
13: 'r'
319323
}[n];
320324
if (x) { return '\\' + x; }
321-
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
325+
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16).toUpperCase();
322326
}
323327

324328
function markBoxed(str) {

test/lowbyte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ test('interpolate low bytes', function (t) {
77
t.plan(1);
88
t.equal(
99
inspect(obj),
10-
"{ x: 'a\\r\\nb', y: '\\x05! \\x1f \\x12' }"
10+
"{ x: 'a\\r\\nb', y: '\\x05! \\x1F \\x12' }"
1111
);
1212
});

0 commit comments

Comments
 (0)