Synchronize implementations of second render logging (#24381)
Minor followup to #24373. The fix for #24373 (comment) didn't get synchronized to the hook implementation.
Billy Janitsch committed
Apr 15, 2022 at 11:35 UTC
726ba80298dad46b331aca1bcb71ca9b2004ed91
2 files changed
+6
-3
packages/react-devtools-shared/src/backend/utils.js
+1
-1
@@ -187,7 +187,7 @@ export function formatWithStyles(
187
return inputArgs;
188
}
189
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)
191
const REGEXP = /([^%]|^)(%([oOdisf]))/g;
192
if (inputArgs[0].match(REGEXP)) {
193
return [`%c${inputArgs[0]}`, style, ...inputArgs.slice(1)];
packages/react-devtools-shared/src/hook.js
+5
-2
@@ -180,13 +180,16 @@ export function installHook(target: any): DevToolsHook | null {
180
inputArgs === undefined ||
181
inputArgs === null ||
182
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)) ||
186
style === undefined
187
) {
188
return inputArgs;
189
}
190
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;
193
if (inputArgs[0].match(REGEXP)) {
194
return [`%c${inputArgs[0]}`, style, ...inputArgs.slice(1)];
195
} else {