prevent JSON.parse fault when search is undefined

This commit is contained in:
卜木 2017-06-28 16:37:25 +08:00 committed by 花裤衩
parent ffd668fb7d
commit 56a048865d

View file

@ -110,7 +110,11 @@
export function param2Obj(url) {
const search = url.split('?')[1];
return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}')
if (search !== undefined) {
return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}');
}
return {};
}
export function html2Text(val) {