| 123456789101112131415161718192021222324252627282930 |
- class LocationSearch {
- obj = {} as any;
- constructor() {
- this.obj = this.str2Obj()
- }
-
- str2Obj() {
- const obj = {} as any;
- const searchArr = location.search.replace("?", "").split("&");
- searchArr.map((str) => {
- const [key, ...value] = str.split("=");
- obj[key] = value.map((item) => {
- return item ? item : "="
- }).join("");
- })
- return obj;
- }
-
- join2Str() {
- const arr = [];
- Object.keys(this.obj).map((key) => {
- if(key != 'token' && key != 'openid') {
- arr.push(`${key}=${this.obj[key]}`)
- }
- });
- return arr.length ? `?${arr.join("&")}` : "";
- }
- }
-
- export default LocationSearch
|