Handle RegExp types in Debug sidebar

Fixes #3245
This commit is contained in:
Nick O'Leary
2021-11-08 20:24:10 +00:00
parent 3e0f080ea7
commit b6570a16b8
2 changed files with 13 additions and 0 deletions

View File

@@ -842,6 +842,9 @@ function encodeObject(msg,opts) {
length: msg.msg.size
}
needsStringify = true;
} else if (msg.msg && msg.msg.constructor.name === "RegExp") {
msg.format = 'regexp';
msg.msg = msg.msg.toString();
}
if (needsStringify || (msg.format === "Object")) {
msg.msg = safeJSONStringify(msg.msg, function(key, value) {
@@ -907,6 +910,12 @@ function encodeObject(msg,opts) {
data: Object.fromEntries(Array.from(value.entries()).slice(0,debuglength)),
length: value.size
}
} else if (value.constructor.name === "RegExp") {
value = {
__enc__: true,
type: "regexp",
data: value.toString()
}
}
} else if (value === undefined) {
value = {