mirror of
https://github.com/alice-lg/alice-lg.git
synced 2024-05-11 05:55:03 +00:00
21 lines
405 B
React
21 lines
405 B
React
|
|
||
|
|
||
|
/*
|
||
|
* Fetch query params from location
|
||
|
*/
|
||
|
export function queryParams() {
|
||
|
if (!window && !window.location && !window.location.search) {
|
||
|
return {}
|
||
|
}
|
||
|
let search = window.location.search.slice(1); // omit ?
|
||
|
let tokens = search.split("&");
|
||
|
let params = {};
|
||
|
for (let t of tokens) {
|
||
|
let kv = t.split("=", 2)
|
||
|
params[kv[0]] = kv[1];
|
||
|
}
|
||
|
return params;
|
||
|
}
|
||
|
|
||
|
|