diff --git a/packages/react-devtools-shared/src/backend/utils.js b/packages/react-devtools-shared/src/backend/utils.js index da911cf94458e..f0f78b7f778b5 100644 --- a/packages/react-devtools-shared/src/backend/utils.js +++ b/packages/react-devtools-shared/src/backend/utils.js @@ -187,7 +187,7 @@ export function formatWithStyles( return inputArgs; } - // Matches any of %(o|O|i|s|f), but not %%(o|O|i|s|f) + // Matches any of %(o|O|d|i|s|f), but not %%(o|O|d|i|s|f) const REGEXP = /([^%]|^)(%([oOdisf]))/g; if (inputArgs[0].match(REGEXP)) { return [`%c${inputArgs[0]}`, style, ...inputArgs.slice(1)]; diff --git a/packages/react-devtools-shared/src/hook.js b/packages/react-devtools-shared/src/hook.js index 1ea54985fab68..ad5b33850b765 100644 --- a/packages/react-devtools-shared/src/hook.js +++ b/packages/react-devtools-shared/src/hook.js @@ -180,13 +180,16 @@ export function installHook(target: any): DevToolsHook | null { inputArgs === undefined || inputArgs === null || inputArgs.length === 0 || - (typeof inputArgs[0] === 'string' && inputArgs[0].includes('%c')) || + // Matches any of %c but not %%c + (typeof inputArgs[0] === 'string' && + inputArgs[0].match(/([^%]|^)(%c)/g)) || style === undefined ) { return inputArgs; } - const REGEXP = /(%?)(%([oOdisf]))/g; + // Matches any of %(o|O|d|i|s|f), but not %%(o|O|d|i|s|f) + const REGEXP = /([^%]|^)(%([oOdisf]))/g; if (inputArgs[0].match(REGEXP)) { return [`%c${inputArgs[0]}`, style, ...inputArgs.slice(1)]; } else {