Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/assets/js/util/common.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/web/assets/js/util/common.js b/web/assets/js/util/common.js
index 563bfd45..8e30bce7 100644
--- a/web/assets/js/util/common.js
+++ b/web/assets/js/util/common.js
@@ -135,3 +135,21 @@ function doAllItemsExist(array1, array2) {
}
return true;
}
+
+function buildURL({ host, port, isTLS, base, path }) {
+ if (!host || host.length === 0) host = window.location.hostname;
+ if (!port || port.length === 0) port = window.location.port;
+
+ if (isTLS === undefined) isTLS = window.location.protocol === "https:";
+
+ const protocol = isTLS ? "https:" : "http:";
+
+ port = String(port);
+ if (port === "" || (isTLS && port === "443") || (!isTLS && port === "80")) {
+ port = "";
+ } else {
+ port = `:${port}`;
+ }
+
+ return `${protocol}//${host}${port}${base}${path}`;
+}