aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--webAO/master.ts14
-rw-r--r--webAO/utils/queryParser.ts3
2 files changed, 15 insertions, 2 deletions
diff --git a/webAO/master.ts b/webAO/master.ts
index 17e5f54..bfd5d34 100644
--- a/webAO/master.ts
+++ b/webAO/master.ts
@@ -143,23 +143,35 @@ function processServerlist(serverlist: AOServer[]) {
let port = 0;
let ws_protocol = '';
let http_protocol = '';
+ let domain = '';
if (server.ws_port) {
port = server.ws_port;
ws_protocol = 'ws';
http_protocol = 'http';
+ domain = 'insecure';
}
if (server.wss_port) {
port = server.wss_port;
ws_protocol = 'wss';
http_protocol = 'https';
+ domain = 'web';
}
if (port === 0 || protocol === '') {
console.warn(`Server ${server.name} has no websocket port, skipping`)
continue;
}
- const clientURL: string = `${http_protocol}://${host}/client.html`;
+ // Replace the first element of the domain with the correct subdomain
+ const domainElements = window.location.hostname.split('.');
+ domainElements[0] = domain;
+ let hostname = domainElements.join('.');
+
+ if (window.location.port) {
+ hostname += `:${window.location.port}`;
+ }
+
+ const clientURL: string = `${http_protocol}://${hostname}/client.html`;
const connect = `${ws_protocol}://${server.ip}:${port}`;
const serverName = server.name;
server.online = `Players: ${server.players}`;
diff --git a/webAO/utils/queryParser.ts b/webAO/utils/queryParser.ts
index a8b82d9..1a3cea6 100644
--- a/webAO/utils/queryParser.ts
+++ b/webAO/utils/queryParser.ts
@@ -10,12 +10,13 @@ interface QueryParams {
}
const queryParser = (): QueryParams => {
+ const protocol = window.location.protocol;
const urlParams = new URLSearchParams(window.location.search);
const queryParams = {
ip: urlParams.get("ip") || "",
connect: urlParams.get("connect") || "",
mode: urlParams.get("mode") || "join",
- asset: urlParams.get("asset") || "http://attorneyoffline.de/base/",
+ asset: urlParams.get("asset") || `${protocol}//attorneyoffline.de/base/`,
theme: urlParams.get("theme") || "default",
serverName: urlParams.get("serverName") || "Attorney Online session",
}