wazuh-kibana-app/util/get-path.js
2017-10-27 09:22:10 +02:00

18 lines
622 B
JavaScript

module.exports = (wapiConfig) => {
let path = wapiConfig.url;
let protocol;
if (wapiConfig.url.startsWith("https://")) {
protocol = "https://";
} else if (wapiConfig.url.startsWith("http://")) {
protocol = "http://";
}
if (path.lastIndexOf("/") > protocol.length) {
path = path.substr(0, path.substr(protocol.length).indexOf("/") + protocol.length) +
":" + wapiConfig.port +
path.substr(path.substr(protocol.length).indexOf("/") + protocol.length);
} else {
path = `${wapiConfig.url}:${wapiConfig.port}`;
}
return path;
};