Handling empty RED.settings.ui in UI node

Hi folks,

In all my UI nodes I use the following code snippet to calculate the ui path of my endpoints:

// By default the UI path in the settings.js file will be in comment:
//     //ui: { path: "ui" },
// But as soon as the user has specified a custom UI path there, we will need to use that path:
//     ui: { path: "mypath" },
var uiPath = ((RED.settings.ui || {}).path) || 'ui';
	
// Create the complete server-side path
uiPath = '/' + uiPath + '/ui_svg_graphics';

// Replace a sequence of multiple slashes (e.g. // or ///) by a single one
uiPath = uiPath.replace(/\/+/g, '/');
	
// Make the unicode conversion available (to the DASHBOARD).
RED.httpNode.get(uiPath + "/:cmd/:value", function(req, res){
   ...
})

And this code snippet is doing well - in all kind of situations - already quite some time!

But last week I got a Github issue. Seems that my endpoint is:

  • unreachable when the settings contain UI: { path: "" }
  • reachable when the settings containg UI: { path: "/" }

Does anybody see what I am doing wrong? I assume it is something stupid, but I don't see it for some reason ... And I also don't want to mess things up for all other users, where it is working fine now ...

Thanks a lot !!!
Bart