Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion splat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { SPLAT } = require('triple-beam');
* https://github.com/nodejs/node/blob/b1c8f15c5f169e021f7c46eb7b219de95fe97603/lib/util.js#L201-L230
* @type {RegExp}
*/
const formatRegExp = /%[scdjifoO%]/g;
const formatRegExp = /%[sdjifoO%]/g;

/**
* Captures the number of escaped % signs in a format string (i.e. %s strings).
Expand Down
19 changes: 19 additions & 0 deletions test/splat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,23 @@ describe('splat', () => {
);
});


it('%c in message with meta | preserves %c and merges meta', assumeSplat(
'hello %c world', [{ robotId: 5 }], info => {
assume(info.message).equals('hello %c world');
assume(info.robotId).equals(5);
}
));

it('%c in message without meta | preserves %c in message', assumeSplat(
'hello %c world', [], 'hello %c world'
));

it('%c mixed with valid specifiers | only interpolates valid specifiers', assumeSplat(
'hello %s %c world', ['test', { robotId: 5 }], info => {
assume(info.message).equals('hello test %c world');
assume(info.robotId).equals(5);
}
));

});