diff options
| author | Ho3ein <ho3ein.sanaei@gmail.com> | 2023-05-31 09:17:02 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-31 09:17:02 +0300 |
| commit | 94fad02737d82817ca69f1f05872b49e769a0cb4 (patch) | |
| tree | 55e7ead217c5a3e82791c0edae6ad44de1ba524f /web/assets | |
| parent | 8442836512d82b705e404bc1749e3000115ba550 (diff) | |
| parent | d694e6eafccad246c63264714897316f671d6428 (diff) | |
Merge pull request #545 from hamid-gh98/main
🔀 New Feature + Fix URLs + Some Improvements 🛠️🌐
Diffstat (limited to 'web/assets')
| -rw-r--r-- | web/assets/js/model/models.js | 3 | ||||
| -rw-r--r-- | web/assets/js/util/common.js | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/web/assets/js/model/models.js b/web/assets/js/model/models.js index 9a5dcc85..e1a766dc 100644 --- a/web/assets/js/model/models.js +++ b/web/assets/js/model/models.js @@ -168,6 +168,7 @@ class AllSetting { constructor(data) { this.webListen = ""; + this.webDomain = ""; this.webPort = 2053; this.webCertFile = ""; this.webKeyFile = ""; @@ -187,7 +188,7 @@ class AllSetting { this.subEnable = false; this.subListen = ""; this.subPort = "2096"; - this.subPath = "sub/"; + this.subPath = "/sub/"; this.subDomain = ""; this.subCertFile = ""; this.subKeyFile = ""; 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}`; +} |
