Skip to content

Commit 10b5b37

Browse files
committed
module: fix require tracing when path contains a quote
1 parent f04ecbb commit 10b5b37

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const {
3737
Boolean,
3838
Error,
3939
JSONParse,
40+
JSONStringify,
4041
ObjectDefineProperty,
4142
ObjectFreeze,
4243
ObjectGetOwnPropertyDescriptor,
@@ -209,7 +210,7 @@ let statCache = null;
209210
*/
210211
function wrapModuleLoad(request, parent, isMain) {
211212
const logLabel = `[${parent?.id || ''}] [${request}]`;
212-
const traceLabel = `require('${request}')`;
213+
const traceLabel = `require(${JSONStringify(request)})`;
213214

214215
startTimer(logLabel, traceLabel);
215216

lib/internal/util/debuglog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function formatTime(ms) {
173173
}
174174

175175
function safeTraceLabel(label) {
176-
return label.replace(/\\/g, '\\\\');
176+
return label.replace(/\\/g, '\\\\').replaceAll('"', '\\"');
177177
}
178178

179179
/**

0 commit comments

Comments
 (0)