Skip to content

Commit 4daec61

Browse files
lib: Update lib/internal/util/inspect.js
Co-authored-by: Ruben Bridgewater <[email protected]>
1 parent 26a46ae commit 4daec61

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/internal/util/inspect.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,10 +1031,20 @@ function getPrefix(constructor, tag, fallback, size = '') {
10311031
return `[${fallback}${size}: null prototype] `;
10321032
}
10331033

1034-
if (tag !== '' && !constructor.includes(tag)) {
1035-
return `${constructor}${size} [${tag}] `;
1034+
let result = `${constructor}${size} `;
1035+
if (tag !== '') {
1036+
const position = constructor.indexOf(tag);
1037+
if (position === -1) {
1038+
result += `[${tag}] `;
1039+
} else {
1040+
const endPos = position + tag.length;
1041+
if (endPos !== constructor.length &&
1042+
constructor[endPos + 1] === constructor[endPos + 1].toLowerCase()) {
1043+
result += `[${tag}] `;
1044+
}
1045+
}
10361046
}
1037-
return `${constructor}${size} `;
1047+
return result;
10381048
}
10391049

10401050
// Look up the keys of the object.

0 commit comments

Comments
 (0)