Skip to content

Commit 6ed1043

Browse files
committed
fix regex
1 parent 99eef9e commit 6ed1043

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/react-devtools-shared/src/backend/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export function formatWithStyles(
188188
}
189189

190190
// Matches any of %(o|O|d|i|s|f), but not %%(o|O|d|i|s|f)
191-
const REGEXP = /([^%]|^)(%([oOdisf]))/g;
191+
const REGEXP = /(?<!%)((%%)*)(%([oOdisf]))/g;
192192
if (inputArgs[0].match(REGEXP)) {
193193
return [`%c${inputArgs[0]}`, style, ...inputArgs.slice(1)];
194194
} else {

packages/react-devtools-shared/src/hook.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export function installHook(target: any): DevToolsHook | null {
189189
}
190190

191191
// Matches any of %(o|O|d|i|s|f), but not %%(o|O|d|i|s|f)
192-
const REGEXP = /([^%]|^)(%([oOdisf]))/g;
192+
const REGEXP = /(?<!%)((%%)*)(%([oOdisf]))/g;
193193
if (inputArgs[0].match(REGEXP)) {
194194
return [`%c${inputArgs[0]}`, style, ...inputArgs.slice(1)];
195195
} else {

0 commit comments

Comments
 (0)