// Input: "https://jsrun.net/new?key1=value1&key2=value2";
// Output: {
// key1:"value1",
// key2:"value2"
// }
let input = "https://jsrun.net/new?key1=value1&key2=value2"
const index = input.indexOf('?')
const obj = {}
// 说明存在参数
if (index > 0) {
let all_query = input.split('?')[1]
let query_arr = all_query.split('&')
query_arr.forEach(item => {
const item_arr = item.split("=")
obj[item_arr[0]] = item_arr[1]
})
}
console.log(obj)