File tree Expand file tree Collapse file tree 2 files changed +20
-20
lines changed
packages/react-native/Libraries/Blob Expand file tree Collapse file tree 2 files changed +20
-20
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ export class URLSearchParams {
1414 _searchParams : Map < string , string [ ] > = new Map ( ) ;
1515
1616 constructor ( params ? : Record < string , string > | string | [ string , string ] [ ] ) {
17-
18- if ( params === null ) {
17+ if ( params === null ) {
1918 return ;
2019 }
2120
@@ -28,7 +27,9 @@ export class URLSearchParams {
2827 if ( ! pair ) {
2928 return ;
3029 }
31- const [ key , value ] = pair . split ( '=' ) . map ( part => decodeURIComponent ( part . replace ( / \+ / g, ' ' ) ) ) ;
30+ const [ key , value ] = pair
31+ . split ( '=' )
32+ . map ( part => decodeURIComponent ( part . replace ( / \+ / g, ' ' ) ) ) ;
3233 this . append ( key , value ) ;
3334 } ) ;
3435 }
@@ -131,16 +132,17 @@ export class URLSearchParams {
131132 }
132133
133134 toString ( ) : string {
134- return Array . from ( this . _searchParams . entries ( ) )
135- . map ( ( [ key , values ] ) =>
136- values
137- . map (
138- value =>
139- `${ encodeURIComponent ( key ) . replace ( / % 2 0 / g, '+' ) } =${ encodeURIComponent ( value )
140- . replace ( / % 2 0 / g, '+' ) } ` // Convert only spaces to '+'
141- )
142- . join ( '&' ) ,
143- )
144- . join ( '&' ) ;
145- }
135+ return Array . from ( this . _searchParams . entries ( ) )
136+ . map ( ( [ key , values ] ) =>
137+ values
138+ . map (
139+ value =>
140+ `${ encodeURIComponent ( key ) . replace ( / % 2 0 / g, '+' ) } =${ encodeURIComponent (
141+ value ,
142+ ) . replace ( / % 2 0 / g, '+' ) } `, // Convert only spaces to '+'
143+ )
144+ . join ( '&' ) ,
145+ )
146+ . join ( '&' ) ;
147+ }
146148}
Original file line number Diff line number Diff line change @@ -63,13 +63,11 @@ describe('URL', function () {
6363 const paramsFromString = new URLSearchParams (
6464 '?param1=value1+value2¶m2=value%20with%20space' ,
6565 ) ;
66-
67-
6866 expect ( paramsFromString . get ( 'param1' ) ) . toBe ( 'value1 value2' ) ;
6967 expect ( paramsFromString . get ( 'param2' ) ) . toBe ( 'value with space' ) ;
70- expect ( paramsFromString . toString ( ) ) . toBe ( 'param1=value1+value2¶m2=value+with+space' ) ;
71-
72-
68+ expect ( paramsFromString . toString ( ) ) . toBe (
69+ 'param1=value1+value2¶m2=value+with+space' ,
70+ ) ;
7371
7472 const paramsFromObject = new URLSearchParams ( {
7573 user : 'john' ,
You can’t perform that action at this time.
0 commit comments