convertURLParameterToObject

源码

https://github.com/ddzy/ts-utility-plugins/tree/master/src/ddzy/utility/others/convertURLParameterToObject

说明

提取URL中的GET请求参数

用法

index.ts
const result = utilityOthers.convertURLParameterToObject(
'https://github.com/ddzy?username=duan&age=20&token=kslgjadg',
);
const result2 = utilityOthers.convertURLParameterToObject(
'https://github.com/ddzy??username=duan&&age=20',
);
const result3 = utilityOthers.convertURLParameterToObject(
'https://github.com/ddzy/username=duan?age=20&token=askndg',
);
const result4 = utilityOthers.convertURLParameterToObject(
'https://github.com/ddzy&username=duan?age=20?token=askndg',
);
// {username: "duan", age: "20", token: "kslgjadg"}
console.log(result);
// {username: "duan", age: "20"}
console.log(result2);
// {age: "20", token: "askndg"}
console.log(result3);
// {age: "20", token: "askndg"}
console.log(result4);