diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/conf-reader/main.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/conf-reader/main.js index 8e02b70ff38..bb97f7202da 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/conf-reader/main.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/conf-reader/main.js @@ -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);