aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/queryParser.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2023-11-13 13:44:33 +0100
committerGitHub <noreply@github.com>2023-11-13 13:44:33 +0100
commit074114f8157aadc1cd85d55aa7a9343872389ee6 (patch)
treeef57dba7ccea154bd0c6eaafa3cba34c15664a3b /webAO/utils/queryParser.ts
parent3b57ceff07be9fc86ee5ba73a0614ee754f8f8c6 (diff)
parentc6b046917f71940f75f5028c64298ec146f9a487 (diff)
Merge pull request #196 from Troid-Tech/query-params-and-name
Rework query param parsing and set window title to server name
Diffstat (limited to 'webAO/utils/queryParser.ts')
-rw-r--r--webAO/utils/queryParser.ts23
1 files changed, 10 insertions, 13 deletions
diff --git a/webAO/utils/queryParser.ts b/webAO/utils/queryParser.ts
index 20863ca..f934ac6 100644
--- a/webAO/utils/queryParser.ts
+++ b/webAO/utils/queryParser.ts
@@ -2,24 +2,21 @@
interface QueryParams {
ip: string;
- serverIP: string;
mode: string;
asset: string;
theme: string;
-}
-
-interface StringMap {
- [key: string]: any;
+ serverName: string;
}
const queryParser = (): QueryParams => {
- const queryDict: StringMap = {};
- location.search
- .substr(1)
- .split("&")
- .forEach((item) => {
- queryDict[item.split("=")[0]] = item.split("=")[1];
- });
- return queryDict as QueryParams;
+ const urlParams = new URLSearchParams(window.location.search);
+ const queryParams = {
+ ip: urlParams.get("ip") || "",
+ mode: urlParams.get("mode") || "join",
+ asset: urlParams.get("asset") || "http://attorneyoffline.de/base/",
+ theme: urlParams.get("theme") || "default",
+ serverName: urlParams.get("serverName") || "Attorney Online session"
+ }
+ return queryParams as QueryParams;
};
export default queryParser;