Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Fix #282 by ignoring %c specifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Nov 9, 2016
1 parent 47a37df commit bce3d60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/chrome/consoleHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ function resolveParams(m: Crdp.Runtime.ConsoleAPICalledEvent): string {
formatted = Math.floor(+param.value);
} else if (formatSpecifiers[i] === 'f') {
formatted = +param.value;
} else if (['o', 'O', 'c'].indexOf(formatSpecifiers[i]) >= 0) {
} else if (formatSpecifiers[i] === 'c') {
// %c - Applies CSS color rules
// Could use terminal color codes in the future
formatted = '';
} else if (['o', 'O'].indexOf(formatSpecifiers[i]) >= 0) {
// Not supported -
// %o - expandable DOM element
// %O - expandable JS object
// %c - Applies CSS color rules
formatted = param.value;
}

Expand Down
4 changes: 4 additions & 0 deletions test/chrome/consoleHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ suite('ConsoleHelper', () => {
doAssert(Runtime.makeLog('test', null, undefined), 'test null undefined');
});

test('strips %c patterns', () => {
doAssert(Runtime.makeLog('foo %cbar', 'color: red'), 'foo bar');
});

test('network error - need Log domain');

test('objects- waiting on Microsoft/vscode-node-debug#4');
Expand Down

0 comments on commit bce3d60

Please sign in to comment.