diff options
Diffstat (limited to 'webAO/utils/queryParser.ts')
| -rw-r--r-- | webAO/utils/queryParser.ts | 23 |
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; |
