File tree Expand file tree Collapse file tree 1 file changed +14
-16
lines changed
Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Original file line number Diff line number Diff line change 11function parseQueryString ( queryString ) {
2+ const queryParams = { } ;
3+ if ( ! queryString ) return queryParams ;
24
3- const queryParams = { } ;
4- if ( ! queryString ) return queryParams ;
5+ const keyValuePairs = queryString . split ( "&" ) ;
56
6- const keyValuePairs = queryString . split ( "&" ) ;
7-
8- for ( const pair of keyValuePairs ) {
9- const index = pair . indexOf ( "=" ) ;
10- if ( index === - 1 ) {
11- queryParams [ decodeURIComponent ( pair ) ] = undefined
12- } else {
13- const key = decodeURIComponent ( pair . slice ( 0 , index ) ) ;
14- const value = decodeURIComponent ( pair . slice ( index + 1 ) ) ;
15- queryParams [ key ] = value ;
16- }
17-
18- return queryParams ;
7+ for ( const pair of keyValuePairs ) {
8+ const index = pair . indexOf ( "=" ) ;
9+ if ( index === - 1 ) {
10+ queryParams [ decodeURIComponent ( pair ) ] = undefined ;
11+ } else {
12+ const key = decodeURIComponent ( pair . slice ( 0 , index ) ) ;
13+ const value = decodeURIComponent ( pair . slice ( index + 1 ) ) ;
14+ queryParams [ key ] = value ;
15+ }
1916
17+ return queryParams ;
2018 }
2119}
2220
23- module . exports = parseQueryString ;
21+ module . exports = parseQueryString ;
You can’t perform that action at this time.
0 commit comments