Skip to content

Commit 56a0488

Browse files
xqbumuPanJiaChen
authored andcommitted
prevent JSON.parse fault when search is undefined
1 parent ffd668f commit 56a0488

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/utils/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@
110110

111111
export function param2Obj(url) {
112112
const search = url.split('?')[1];
113-
return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}')
113+
if (search !== undefined) {
114+
return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}');
115+
}
116+
return {};
117+
114118
}
115119

116120
export function html2Text(val) {

0 commit comments

Comments
 (0)