aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/queryParser.ts
blob: 3110c14e2189f9debd3f82fe459927ff9eac56aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
interface QueryParams {
  ip: string;
  serverIP: string;
  mode: string;
  asset: string;
  theme: string;
}
interface StringMap {
  [key: string]: any;
}

const queryParser = (): QueryParams => {
  const queryDict: StringMap = {};
  location.search
    .substr(1)
    .split("&")
    .forEach((item) => {
      queryDict[item.split("=")[0]] = item.split("=")[1];
    });
  return queryDict as QueryParams;
};
export default queryParser;