mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add RED.utils.parseContextKey
This commit is contained in:
parent
f8aa4a9588
commit
d8cf86fd6f
@ -15,16 +15,11 @@
|
||||
**/
|
||||
(function($) {
|
||||
var contextParse = function(v) {
|
||||
var parts = {};
|
||||
var m = /^#:\((\S+?)\)::(.*)$/.exec(v);
|
||||
if (m) {
|
||||
parts.option = m[1];
|
||||
parts.value = m[2];
|
||||
} else {
|
||||
parts.value = v;
|
||||
parts.option = RED.settings.context.default;
|
||||
var parts = RED.utils.parseContextKey(v);
|
||||
return {
|
||||
option: parts.store,
|
||||
value: parts.key
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
var contextExport = function(v,opt) {
|
||||
if (!opt) {
|
||||
|
@ -828,6 +828,20 @@ RED.utils = (function() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
function parseContextKey(key) {
|
||||
var parts = {};
|
||||
var m = /^#:\((\S+?)\)::(.*)$/.exec(key);
|
||||
if (m) {
|
||||
parts.store = m[1];
|
||||
parts.key = m[2];
|
||||
} else {
|
||||
parts.key = key;
|
||||
if (RED.settings.context) {
|
||||
parts.store = RED.settings.context.default;
|
||||
}
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
return {
|
||||
createObjectElement: buildMessageElement,
|
||||
@ -839,6 +853,7 @@ RED.utils = (function() {
|
||||
getNodeIcon: getNodeIcon,
|
||||
getNodeLabel: getNodeLabel,
|
||||
addSpinnerOverlay: addSpinnerOverlay,
|
||||
decodeObject: decodeObject
|
||||
decodeObject: decodeObject,
|
||||
parseContextKey: parseContextKey
|
||||
}
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user