Skip to content

Commit 5521193

Browse files
author
Ritesh Shukla
committed
Fixing Nits :)
1 parent 24713b8 commit 5521193

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

packages/react-native/Libraries/Blob/URLSearchParams.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff 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
}

packages/react-native/Libraries/Blob/__tests__/URL-test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff 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&param2=value%20with%20space',
64+
[
65+
'?param1=value1',
66+
'&param2=value2%20with%20spaces',
67+
'&param3=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&param2=value+with+space',
74+
'param1=value1&param2=value2+with+spaces&param3=value3+with+spaces+legacy',
7075
);
7176

7277
const paramsFromObject = new URLSearchParams({

0 commit comments

Comments
 (0)