Skip to content

Commit 726ba80

Browse files
Synchronize implementations of second render logging (#24381)
Minor followup to #24373. The fix for #24373 (comment) didn't get synchronized to the hook implementation.
1 parent d63cd97 commit 726ba80

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export function formatWithStyles(
187187
return inputArgs;
188188
}
189189

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

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,16 @@ export function installHook(target: any): DevToolsHook | null {
180180
inputArgs === undefined ||
181181
inputArgs === null ||
182182
inputArgs.length === 0 ||
183-
(typeof inputArgs[0] === 'string' && inputArgs[0].includes('%c')) ||
183+
// Matches any of %c but not %%c
184+
(typeof inputArgs[0] === 'string' &&
185+
inputArgs[0].match(/([^%]|^)(%c)/g)) ||
184186
style === undefined
185187
) {
186188
return inputArgs;
187189
}
188190

189-
const REGEXP = /(%?)(%([oOdisf]))/g;
191+
// Matches any of %(o|O|d|i|s|f), but not %%(o|O|d|i|s|f)
192+
const REGEXP = /([^%]|^)(%([oOdisf]))/g;
190193
if (inputArgs[0].match(REGEXP)) {
191194
return [`%c${inputArgs[0]}`, style, ...inputArgs.slice(1)];
192195
} else {

0 commit comments

Comments
 (0)