From 83ffa4091d27cd67e1add4720a64175536ade60a Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Thu, 2 Jan 2020 13:36:33 +0100 Subject: [PATCH] Fix errors when profilesUrl is not defined in config (text undefined) --- js/control/Profile.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/control/Profile.js b/js/control/Profile.js index 9430abb..b955bd3 100644 --- a/js/control/Profile.js +++ b/js/control/Profile.js @@ -134,6 +134,8 @@ BR.Profile = L.Evented.extend({ }, _setValue: function(profileText, profileEditorActivated) { + profileText = profileText || ''; + if (L.DomUtil.get('profile_editor').classList.contains('active')) { // Set value of the full editor and exit this.editor.setValue(profileText); @@ -141,17 +143,19 @@ BR.Profile = L.Evented.extend({ return; } + if (!profileText) return; + // Otherwise, create user friendly form + var params = {}; var global = profileText.split('---context:').filter(function(e) { return e.startsWith('global'); }); - if (global) { + if (global && global.length > 0) { // Remove ---context:global line global = global[0].split('\n').slice(1); // Comment is mandatory var assignRegex = /assign\s*(\w*)\s*=?\s*([\w\.]*)\s*#\s*%(.*)%\s*(\|\s*(.*)\s*\|\s*(.*)\s*)?$/; - var params = {}; global.forEach(function(item) { var match = item.match(assignRegex); var value;