refactor: change mock files to commonjs

This commit is contained in:
花裤衩
2020-06-15 17:07:49 +08:00
parent efc976ae5a
commit 5c87772025
6 changed files with 37 additions and 15 deletions

23
mock/utils.js Normal file
View File

@@ -0,0 +1,23 @@
/**
* @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
}