mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3251 from node-red/regex-debug
Handle RegExp types in Debug sidebar
This commit is contained in:
commit
ed6afcd802
@ -142,6 +142,8 @@ RED.utils = (function() {
|
||||
result = $('<span class="red-ui-debug-msg-object-value red-ui-debug-msg-type-meta"></span>').text('function');
|
||||
} else if (value.hasOwnProperty('type') && (value.type === 'number' || value.type === 'bigint')) {
|
||||
result = $('<span class="red-ui-debug-msg-object-value red-ui-debug-msg-type-number"></span>').text(value.data);
|
||||
} else if (value.hasOwnProperty('type') && value.type === 'regexp') {
|
||||
result = $('<span class="red-ui-debug-msg-object-value red-ui-debug-msg-type-string"></span>').text(value.data);
|
||||
} else {
|
||||
result = $('<span class="red-ui-debug-msg-object-value red-ui-debug-msg-type-meta">object</span>');
|
||||
}
|
||||
@ -440,6 +442,8 @@ RED.utils = (function() {
|
||||
$('<span class="red-ui-debug-msg-type-null">undefined</span>').appendTo(entryObj);
|
||||
} else if (obj.__enc__ && (obj.type === 'number' || obj.type === 'bigint')) {
|
||||
e = $('<span class="red-ui-debug-msg-type-number red-ui-debug-msg-object-header"></span>').text(obj.data).appendTo(entryObj);
|
||||
} else if (typeHint === "regexp" || (obj.__enc__ && obj.type === 'regexp')) {
|
||||
e = $('<span class="red-ui-debug-msg-type-string red-ui-debug-msg-object-header"></span>').text((typeof obj === "string")?obj:obj.data).appendTo(entryObj);
|
||||
} else if (typeHint === "function" || (obj.__enc__ && obj.type === 'function')) {
|
||||
e = $('<span class="red-ui-debug-msg-type-meta red-ui-debug-msg-object-header"></span>').text("function").appendTo(entryObj);
|
||||
} else if (typeHint === "internal" || (obj.__enc__ && obj.type === 'internal')) {
|
||||
|
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user