24 lines
385 B
JavaScript
24 lines
385 B
JavaScript
|
/**
|
||
|
* @param {string} url
|
||
|
* @returns {Object}
|
||
|
*/
|
||
|
function param2Obj(url) {
|
||
|
const search = url.split('?')[1]
|
||
|
if (!search) {
|
||
|
return {}
|
||
|
}
|
||
|
return JSON.parse(
|
||
|
'{"' +
|
||
|
decodeURIComponent(search)
|
||
|
.replace(/"/g, '\\"')
|
||
|
.replace(/&/g, '","')
|
||
|
.replace(/=/g, '":"')
|
||
|
.replace(/\+/g, ' ') +
|
||
|
'"}'
|
||
|
)
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
param2Obj
|
||
|
}
|