Now UI configs supports system parameters with eg. %iot.core.host%

revert-70aa11f8
Rasika Perera 8 years ago
parent 27e953cda3
commit 252eb78124

@ -36,8 +36,23 @@ var conf = function () {
} else if ((typeof value === "string") && value.indexOf("%server.ip%") > -1) {
var getProperty = require("process").getProperty;
return value.replace("%server.ip%", getProperty("carbon.local.ip"));
} else {
var paramPattern = new RegExp("%(.*?)%", "g");
var out = value;
while ((matches = paramPattern.exec(value)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (matches.index === paramPattern.lastIndex) {
paramPattern.lastIndex++;
}
if (matches.length == 2) {
var property = process.getProperty(matches[1]);
if (property) {
out = out.replace(new RegExp("%" + matches[1] + "%", "g"), property);
}
}
}
return out;
}
return value;
}
);
application.put("CONF", conf);

Loading…
Cancel
Save