|
2 | 2 |
|
3 | 3 | const {
|
4 | 4 | Array,
|
| 5 | + ArrayIsArray, |
5 | 6 | ArrayPrototypeJoin,
|
6 | 7 | ArrayPrototypeMap,
|
7 | 8 | ArrayPrototypePush,
|
@@ -211,7 +212,17 @@ class URLSearchParams {
|
211 | 212 | const desc = ReflectGetOwnPropertyDescriptor(init, key);
|
212 | 213 | if (desc !== undefined && desc.enumerable) {
|
213 | 214 | const typedKey = toUSVString(key);
|
214 |
| - const typedValue = toUSVString(init[key]); |
| 215 | + let typedValue = ''; |
| 216 | + if (ArrayIsArray(init[key])) { |
| 217 | + const len = init[key].length; |
| 218 | + for (let j = 0; j < len; j++) { |
| 219 | + typedValue += toUSVString(init[key][j]); |
| 220 | + if (j < len - 1) |
| 221 | + typedValue += ','; |
| 222 | + } |
| 223 | + } else { |
| 224 | + typedValue = toUSVString(init[key]); |
| 225 | + } |
215 | 226 |
|
216 | 227 | // Two different key may result same after `toUSVString()`, we only
|
217 | 228 | // leave the later one. Refers to WPT.
|
@@ -1017,12 +1028,17 @@ function serializeParams(array) {
|
1017 | 1028 |
|
1018 | 1029 | const firstEncodedParam = encodeStr(array[0], noEscape, paramHexTable);
|
1019 | 1030 | const firstEncodedValue = encodeStr(array[1], noEscape, paramHexTable);
|
1020 |
| - let output = `${firstEncodedParam}=${firstEncodedValue}`; |
| 1031 | + let output = firstEncodedParam; |
| 1032 | + output += '='; |
| 1033 | + output += firstEncodedValue; |
1021 | 1034 |
|
1022 | 1035 | for (let i = 2; i < len; i += 2) {
|
1023 | 1036 | const encodedParam = encodeStr(array[i], noEscape, paramHexTable);
|
1024 | 1037 | const encodedValue = encodeStr(array[i + 1], noEscape, paramHexTable);
|
1025 |
| - output += `&${encodedParam}=${encodedValue}`; |
| 1038 | + output += '&'; |
| 1039 | + output += encodedParam; |
| 1040 | + output += '='; |
| 1041 | + output += encodedValue; |
1026 | 1042 | }
|
1027 | 1043 |
|
1028 | 1044 | return output;
|
|
0 commit comments