File tree 2 files changed +13
-11
lines changed
2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 3
3
* @returns {Object }
4
4
*/
5
5
function param2Obj ( url ) {
6
- const search = url . split ( '?' ) [ 1 ]
6
+ const search = decodeURIComponent ( url . split ( '?' ) [ 1 ] ) . replace ( / \+ / g , ' ' )
7
7
if ( ! search ) {
8
8
return { }
9
9
}
10
- return JSON . parse (
11
- '{"' +
12
- decodeURIComponent ( search )
13
- . replace ( / " / g, '\\"' )
14
- . replace ( / & / g, '","' )
15
- . replace ( / = / g, '":"' )
16
- . replace ( / \+ / g, ' ' ) +
17
- '"}'
18
- )
10
+ const obj = { }
11
+ const searchArr = search . split ( '&' )
12
+ searchArr . forEach ( v => {
13
+ const index = v . indexOf ( '=' )
14
+ if ( index !== - 1 ) {
15
+ const name = v . substring ( 0 , index )
16
+ const val = v . substring ( index + 1 , v . length )
17
+ obj [ name ] = val
18
+ }
19
+ } )
20
+ return obj
19
21
}
20
22
21
23
/**
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ module.exports = {
53
53
// config.plugins.delete('preload')
54
54
55
55
// when there are many pages, it will cause too many meaningless requests
56
- config . plugins . delete ( 'prefetch' ) //
56
+ config . plugins . delete ( 'prefetch' )
57
57
58
58
// set svg-sprite-loader
59
59
config . module
You can’t perform that action at this time.
0 commit comments