File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed
Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,18 @@ function parseQueryString(queryString) {
1010 const cleaned = queryString . startsWith ( "?" )
1111 ? queryString . slice ( 1 )
1212 : queryString ;
13- const keyValuePairs = cleaned . split ( "&" ) . filter ( Boolean ) ;
14-
15- for ( const pair of keyValuePairs ) {
16- // Only split on the first =
17- const equalIndex = pair . indexOf ( "=" ) ;
18-
19- if ( equalIndex === - 1 ) {
20- // key without = → value is empty string
21- queryParams [ pair ] = "" ;
22- } else {
23- const key = pair . slice ( 0 , equalIndex ) ;
24- const value = pair . slice ( equalIndex + 1 ) ;
13+
14+ // Split into segments and ignore empty ones
15+ const segments = cleaned . split ( "&" ) . filter ( Boolean ) ;
16+
17+ for ( const segment of segments ) {
18+ // Split only on the first =, but everything after is a value
19+ const eqIndex = segment . indexOf ( "=" ) ;
20+
21+ const key = eqIndex === - 1 ? segment : segment . slice ( 0 , eqIndex ) ;
22+ const value = eqIndex === - 1 ? "" : segment . slice ( eqIndex + 1 ) ;
23+
24+ if ( key ) {
2525 queryParams [ key ] = value ;
2626 }
2727 }
You can’t perform that action at this time.
0 commit comments