File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
packages/react-native/Libraries/Blob Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ export class URLSearchParams {
1818 return ;
1919 }
2020
21- // URLSearchParams("key1=value1&key2=value2");
2221 if ( typeof params === 'string' ) {
22+ // URLSearchParams("key1=value1&key2=value2");
2323 params
2424 . replace ( / ^ \? / , '' )
2525 . split ( '&' )
@@ -32,14 +32,11 @@ export class URLSearchParams {
3232 . map ( part => decodeURIComponent ( part . replace ( / \+ / g, ' ' ) ) ) ;
3333 this . append ( key , value ) ;
3434 } ) ;
35- }
36-
37- //URLSearchParams([["key1", "value1"], ["key2", "value2"]]);
38- else if ( Array . isArray ( params ) ) {
35+ } else if ( Array . isArray ( params ) ) {
36+ //URLSearchParams([["key1", "value1"], ["key2", "value2"]]);
3937 params . forEach ( ( [ key , value ] ) => this . append ( key , value ) ) ;
40- }
41- //URLSearchParams({ key1: "value1", key2: "value2" });
42- else if ( typeof params === 'object' ) {
38+ } else if ( typeof params === 'object' ) {
39+ //URLSearchParams({ key1: "value1", key2: "value2" });
4340 Object . entries ( params ) . forEach ( ( [ key , value ] ) => this . append ( key , value ) ) ;
4441 }
4542 }
Original file line number Diff line number Diff line change @@ -61,12 +61,17 @@ describe('URL', function () {
6161 expect ( searchParams . get ( 'key' ) ) . toBe ( 'value' ) ;
6262
6363 const paramsFromString = new URLSearchParams (
64- '?param1=value1+value2¶m2=value%20with%20space' ,
64+ [
65+ '?param1=value1' ,
66+ '¶m2=value2%20with%20spaces' ,
67+ '¶m3=value3+with+spaces+legacy' ,
68+ ] . join ( '' ) ,
6569 ) ;
66- expect ( paramsFromString . get ( 'param1' ) ) . toBe ( 'value1 value2' ) ;
67- expect ( paramsFromString . get ( 'param2' ) ) . toBe ( 'value with space' ) ;
70+ expect ( paramsFromString . get ( 'param1' ) ) . toBe ( 'value1' ) ;
71+ expect ( paramsFromString . get ( 'param2' ) ) . toBe ( 'value2 with spaces' ) ;
72+ expect ( paramsFromString . get ( 'param3' ) ) . toBe ( 'value3 with spaces legacy' ) ;
6873 expect ( paramsFromString . toString ( ) ) . toBe (
69- 'param1=value1+value2 ¶m2=value +with+space ' ,
74+ 'param1=value1¶m2=value2 +with+spaces¶m3=value3+with+spaces+legacy ' ,
7075 ) ;
7176
7277 const paramsFromObject = new URLSearchParams ( {
You can’t perform that action at this time.
0 commit comments