whatwg-url 6.4.0 → 6.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/URL-impl.js +6 -0
- package/lib/URL.js +171 -31
- package/lib/URLSearchParams.js +111 -42
- package/lib/url-state-machine.js +9 -2
- package/lib/urlencoded.js +3 -3
- package/lib/utils.js +47 -7
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ The following methods are exported for use by places like jsdom that need to imp
|
|
|
21
21
|
- [URL serializer](https://url.spec.whatwg.org/#concept-url-serializer): `serializeURL(urlRecord, excludeFragment)`
|
|
22
22
|
- [Host serializer](https://url.spec.whatwg.org/#concept-host-serializer): `serializeHost(hostFromURLRecord)`
|
|
23
23
|
- [Serialize an integer](https://url.spec.whatwg.org/#serialize-an-integer): `serializeInteger(number)`
|
|
24
|
-
- [Origin](https://url.spec.whatwg.org/#concept-url-origin) [serializer](https://html.spec.whatwg.org/multipage/
|
|
24
|
+
- [Origin](https://url.spec.whatwg.org/#concept-url-origin) [serializer](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin): `serializeURLOrigin(urlRecord)`
|
|
25
25
|
- [Set the username](https://url.spec.whatwg.org/#set-the-username): `setTheUsername(urlRecord, usernameString)`
|
|
26
26
|
- [Set the password](https://url.spec.whatwg.org/#set-the-password): `setThePassword(urlRecord, passwordString)`
|
|
27
27
|
- [Cannot have a username/password/port](https://url.spec.whatwg.org/#cannot-have-a-username-password-port): `cannotHaveAUsernamePasswordPort(urlRecord)`
|
package/lib/URL-impl.js
CHANGED
|
@@ -42,6 +42,12 @@ exports.implementation = class URLImpl {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
this._url = parsedURL;
|
|
45
|
+
|
|
46
|
+
this._query._list.splice(0);
|
|
47
|
+
const { query } = parsedURL;
|
|
48
|
+
if (query !== null) {
|
|
49
|
+
this._query._list = urlencoded.parseUrlencoded(query);
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
get origin() {
|
package/lib/URL.js
CHANGED
|
@@ -2,23 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
const conversions = require("webidl-conversions");
|
|
4
4
|
const utils = require("./utils.js");
|
|
5
|
+
|
|
5
6
|
const impl = utils.implSymbol;
|
|
6
7
|
|
|
7
8
|
function URL(url) {
|
|
8
9
|
if (!new.target) {
|
|
9
10
|
throw new TypeError(
|
|
10
|
-
"Failed to construct 'URL'. Please use the 'new' operator; this constructor cannot be called as a function."
|
|
11
|
+
"Failed to construct 'URL'. Please use the 'new' operator; this constructor " + "cannot be called as a function."
|
|
11
12
|
);
|
|
12
13
|
}
|
|
13
14
|
if (arguments.length < 1) {
|
|
14
|
-
throw new TypeError(
|
|
15
|
+
throw new TypeError(
|
|
16
|
+
"Failed to construct 'URL': 1 " + "argument required, but only " + arguments.length + " present."
|
|
17
|
+
);
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
const args = [];
|
|
18
21
|
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
|
19
22
|
args[i] = arguments[i];
|
|
20
23
|
}
|
|
24
|
+
|
|
21
25
|
args[0] = conversions["USVString"](args[0], { context: "Failed to construct 'URL': parameter 1" });
|
|
26
|
+
|
|
22
27
|
if (args[1] !== undefined) {
|
|
23
28
|
args[1] = conversions["USVString"](args[1], { context: "Failed to construct 'URL': parameter 2" });
|
|
24
29
|
}
|
|
@@ -26,20 +31,40 @@ function URL(url) {
|
|
|
26
31
|
iface.setup(this, args);
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
Object.defineProperty(URL, "prototype", {
|
|
35
|
+
value: URL.prototype,
|
|
36
|
+
writable: false,
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: false
|
|
39
|
+
});
|
|
40
|
+
|
|
29
41
|
URL.prototype.toJSON = function toJSON() {
|
|
30
42
|
if (!this || !module.exports.is(this)) {
|
|
31
43
|
throw new TypeError("Illegal invocation");
|
|
32
44
|
}
|
|
45
|
+
|
|
33
46
|
return this[impl].toJSON();
|
|
34
47
|
};
|
|
48
|
+
|
|
35
49
|
Object.defineProperty(URL.prototype, "href", {
|
|
36
50
|
get() {
|
|
37
|
-
|
|
51
|
+
if (!this || !module.exports.is(this)) {
|
|
52
|
+
throw new TypeError("Illegal invocation");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return this[impl]["href"];
|
|
38
56
|
},
|
|
57
|
+
|
|
39
58
|
set(V) {
|
|
59
|
+
if (!this || !module.exports.is(this)) {
|
|
60
|
+
throw new TypeError("Illegal invocation");
|
|
61
|
+
}
|
|
62
|
+
|
|
40
63
|
V = conversions["USVString"](V, { context: "Failed to set the 'href' property on 'URL': The provided value" });
|
|
41
|
-
|
|
64
|
+
|
|
65
|
+
this[impl]["href"] = V;
|
|
42
66
|
},
|
|
67
|
+
|
|
43
68
|
enumerable: true,
|
|
44
69
|
configurable: true
|
|
45
70
|
});
|
|
@@ -48,131 +73,240 @@ URL.prototype.toString = function toString() {
|
|
|
48
73
|
if (!this || !module.exports.is(this)) {
|
|
49
74
|
throw new TypeError("Illegal invocation");
|
|
50
75
|
}
|
|
51
|
-
return this[impl]
|
|
76
|
+
return this[impl]["href"];
|
|
52
77
|
};
|
|
53
78
|
|
|
54
79
|
Object.defineProperty(URL.prototype, "origin", {
|
|
55
80
|
get() {
|
|
56
|
-
|
|
81
|
+
if (!this || !module.exports.is(this)) {
|
|
82
|
+
throw new TypeError("Illegal invocation");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return this[impl]["origin"];
|
|
57
86
|
},
|
|
87
|
+
|
|
58
88
|
enumerable: true,
|
|
59
89
|
configurable: true
|
|
60
90
|
});
|
|
61
91
|
|
|
62
92
|
Object.defineProperty(URL.prototype, "protocol", {
|
|
63
93
|
get() {
|
|
64
|
-
|
|
94
|
+
if (!this || !module.exports.is(this)) {
|
|
95
|
+
throw new TypeError("Illegal invocation");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return this[impl]["protocol"];
|
|
65
99
|
},
|
|
100
|
+
|
|
66
101
|
set(V) {
|
|
102
|
+
if (!this || !module.exports.is(this)) {
|
|
103
|
+
throw new TypeError("Illegal invocation");
|
|
104
|
+
}
|
|
105
|
+
|
|
67
106
|
V = conversions["USVString"](V, { context: "Failed to set the 'protocol' property on 'URL': The provided value" });
|
|
68
|
-
|
|
107
|
+
|
|
108
|
+
this[impl]["protocol"] = V;
|
|
69
109
|
},
|
|
110
|
+
|
|
70
111
|
enumerable: true,
|
|
71
112
|
configurable: true
|
|
72
113
|
});
|
|
73
114
|
|
|
74
115
|
Object.defineProperty(URL.prototype, "username", {
|
|
75
116
|
get() {
|
|
76
|
-
|
|
117
|
+
if (!this || !module.exports.is(this)) {
|
|
118
|
+
throw new TypeError("Illegal invocation");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return this[impl]["username"];
|
|
77
122
|
},
|
|
123
|
+
|
|
78
124
|
set(V) {
|
|
125
|
+
if (!this || !module.exports.is(this)) {
|
|
126
|
+
throw new TypeError("Illegal invocation");
|
|
127
|
+
}
|
|
128
|
+
|
|
79
129
|
V = conversions["USVString"](V, { context: "Failed to set the 'username' property on 'URL': The provided value" });
|
|
80
|
-
|
|
130
|
+
|
|
131
|
+
this[impl]["username"] = V;
|
|
81
132
|
},
|
|
133
|
+
|
|
82
134
|
enumerable: true,
|
|
83
135
|
configurable: true
|
|
84
136
|
});
|
|
85
137
|
|
|
86
138
|
Object.defineProperty(URL.prototype, "password", {
|
|
87
139
|
get() {
|
|
88
|
-
|
|
140
|
+
if (!this || !module.exports.is(this)) {
|
|
141
|
+
throw new TypeError("Illegal invocation");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return this[impl]["password"];
|
|
89
145
|
},
|
|
146
|
+
|
|
90
147
|
set(V) {
|
|
148
|
+
if (!this || !module.exports.is(this)) {
|
|
149
|
+
throw new TypeError("Illegal invocation");
|
|
150
|
+
}
|
|
151
|
+
|
|
91
152
|
V = conversions["USVString"](V, { context: "Failed to set the 'password' property on 'URL': The provided value" });
|
|
92
|
-
|
|
153
|
+
|
|
154
|
+
this[impl]["password"] = V;
|
|
93
155
|
},
|
|
156
|
+
|
|
94
157
|
enumerable: true,
|
|
95
158
|
configurable: true
|
|
96
159
|
});
|
|
97
160
|
|
|
98
161
|
Object.defineProperty(URL.prototype, "host", {
|
|
99
162
|
get() {
|
|
100
|
-
|
|
163
|
+
if (!this || !module.exports.is(this)) {
|
|
164
|
+
throw new TypeError("Illegal invocation");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return this[impl]["host"];
|
|
101
168
|
},
|
|
169
|
+
|
|
102
170
|
set(V) {
|
|
171
|
+
if (!this || !module.exports.is(this)) {
|
|
172
|
+
throw new TypeError("Illegal invocation");
|
|
173
|
+
}
|
|
174
|
+
|
|
103
175
|
V = conversions["USVString"](V, { context: "Failed to set the 'host' property on 'URL': The provided value" });
|
|
104
|
-
|
|
176
|
+
|
|
177
|
+
this[impl]["host"] = V;
|
|
105
178
|
},
|
|
179
|
+
|
|
106
180
|
enumerable: true,
|
|
107
181
|
configurable: true
|
|
108
182
|
});
|
|
109
183
|
|
|
110
184
|
Object.defineProperty(URL.prototype, "hostname", {
|
|
111
185
|
get() {
|
|
112
|
-
|
|
186
|
+
if (!this || !module.exports.is(this)) {
|
|
187
|
+
throw new TypeError("Illegal invocation");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return this[impl]["hostname"];
|
|
113
191
|
},
|
|
192
|
+
|
|
114
193
|
set(V) {
|
|
194
|
+
if (!this || !module.exports.is(this)) {
|
|
195
|
+
throw new TypeError("Illegal invocation");
|
|
196
|
+
}
|
|
197
|
+
|
|
115
198
|
V = conversions["USVString"](V, { context: "Failed to set the 'hostname' property on 'URL': The provided value" });
|
|
116
|
-
|
|
199
|
+
|
|
200
|
+
this[impl]["hostname"] = V;
|
|
117
201
|
},
|
|
202
|
+
|
|
118
203
|
enumerable: true,
|
|
119
204
|
configurable: true
|
|
120
205
|
});
|
|
121
206
|
|
|
122
207
|
Object.defineProperty(URL.prototype, "port", {
|
|
123
208
|
get() {
|
|
124
|
-
|
|
209
|
+
if (!this || !module.exports.is(this)) {
|
|
210
|
+
throw new TypeError("Illegal invocation");
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return this[impl]["port"];
|
|
125
214
|
},
|
|
215
|
+
|
|
126
216
|
set(V) {
|
|
217
|
+
if (!this || !module.exports.is(this)) {
|
|
218
|
+
throw new TypeError("Illegal invocation");
|
|
219
|
+
}
|
|
220
|
+
|
|
127
221
|
V = conversions["USVString"](V, { context: "Failed to set the 'port' property on 'URL': The provided value" });
|
|
128
|
-
|
|
222
|
+
|
|
223
|
+
this[impl]["port"] = V;
|
|
129
224
|
},
|
|
225
|
+
|
|
130
226
|
enumerable: true,
|
|
131
227
|
configurable: true
|
|
132
228
|
});
|
|
133
229
|
|
|
134
230
|
Object.defineProperty(URL.prototype, "pathname", {
|
|
135
231
|
get() {
|
|
136
|
-
|
|
232
|
+
if (!this || !module.exports.is(this)) {
|
|
233
|
+
throw new TypeError("Illegal invocation");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return this[impl]["pathname"];
|
|
137
237
|
},
|
|
238
|
+
|
|
138
239
|
set(V) {
|
|
240
|
+
if (!this || !module.exports.is(this)) {
|
|
241
|
+
throw new TypeError("Illegal invocation");
|
|
242
|
+
}
|
|
243
|
+
|
|
139
244
|
V = conversions["USVString"](V, { context: "Failed to set the 'pathname' property on 'URL': The provided value" });
|
|
140
|
-
|
|
245
|
+
|
|
246
|
+
this[impl]["pathname"] = V;
|
|
141
247
|
},
|
|
248
|
+
|
|
142
249
|
enumerable: true,
|
|
143
250
|
configurable: true
|
|
144
251
|
});
|
|
145
252
|
|
|
146
253
|
Object.defineProperty(URL.prototype, "search", {
|
|
147
254
|
get() {
|
|
148
|
-
|
|
255
|
+
if (!this || !module.exports.is(this)) {
|
|
256
|
+
throw new TypeError("Illegal invocation");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return this[impl]["search"];
|
|
149
260
|
},
|
|
261
|
+
|
|
150
262
|
set(V) {
|
|
263
|
+
if (!this || !module.exports.is(this)) {
|
|
264
|
+
throw new TypeError("Illegal invocation");
|
|
265
|
+
}
|
|
266
|
+
|
|
151
267
|
V = conversions["USVString"](V, { context: "Failed to set the 'search' property on 'URL': The provided value" });
|
|
152
|
-
|
|
268
|
+
|
|
269
|
+
this[impl]["search"] = V;
|
|
153
270
|
},
|
|
271
|
+
|
|
154
272
|
enumerable: true,
|
|
155
273
|
configurable: true
|
|
156
274
|
});
|
|
157
275
|
|
|
158
276
|
Object.defineProperty(URL.prototype, "searchParams", {
|
|
159
277
|
get() {
|
|
278
|
+
if (!this || !module.exports.is(this)) {
|
|
279
|
+
throw new TypeError("Illegal invocation");
|
|
280
|
+
}
|
|
281
|
+
|
|
160
282
|
return utils.getSameObject(this, "searchParams", () => {
|
|
161
|
-
return utils.tryWrapperForImpl(this[impl]
|
|
283
|
+
return utils.tryWrapperForImpl(this[impl]["searchParams"]);
|
|
162
284
|
});
|
|
163
285
|
},
|
|
286
|
+
|
|
164
287
|
enumerable: true,
|
|
165
288
|
configurable: true
|
|
166
289
|
});
|
|
167
290
|
|
|
168
291
|
Object.defineProperty(URL.prototype, "hash", {
|
|
169
292
|
get() {
|
|
170
|
-
|
|
293
|
+
if (!this || !module.exports.is(this)) {
|
|
294
|
+
throw new TypeError("Illegal invocation");
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return this[impl]["hash"];
|
|
171
298
|
},
|
|
299
|
+
|
|
172
300
|
set(V) {
|
|
301
|
+
if (!this || !module.exports.is(this)) {
|
|
302
|
+
throw new TypeError("Illegal invocation");
|
|
303
|
+
}
|
|
304
|
+
|
|
173
305
|
V = conversions["USVString"](V, { context: "Failed to set the 'hash' property on 'URL': The provided value" });
|
|
174
|
-
|
|
306
|
+
|
|
307
|
+
this[impl]["hash"] = V;
|
|
175
308
|
},
|
|
309
|
+
|
|
176
310
|
enumerable: true,
|
|
177
311
|
configurable: true
|
|
178
312
|
});
|
|
@@ -220,37 +354,43 @@ const iface = {
|
|
|
220
354
|
}
|
|
221
355
|
throw new TypeError(`${context} is not of type 'URL'.`);
|
|
222
356
|
},
|
|
357
|
+
|
|
223
358
|
create(constructorArgs, privateData) {
|
|
224
359
|
let obj = Object.create(URL.prototype);
|
|
225
|
-
this.setup(obj, constructorArgs, privateData);
|
|
360
|
+
obj = this.setup(obj, constructorArgs, privateData);
|
|
226
361
|
return obj;
|
|
227
362
|
},
|
|
228
363
|
createImpl(constructorArgs, privateData) {
|
|
229
364
|
let obj = Object.create(URL.prototype);
|
|
230
|
-
this.setup(obj, constructorArgs, privateData);
|
|
365
|
+
obj = this.setup(obj, constructorArgs, privateData);
|
|
231
366
|
return utils.implForWrapper(obj);
|
|
232
367
|
},
|
|
233
368
|
_internalSetup(obj) {},
|
|
234
369
|
setup(obj, constructorArgs, privateData) {
|
|
235
370
|
if (!privateData) privateData = {};
|
|
371
|
+
|
|
236
372
|
privateData.wrapper = obj;
|
|
237
373
|
|
|
238
374
|
this._internalSetup(obj);
|
|
239
|
-
|
|
240
375
|
Object.defineProperty(obj, impl, {
|
|
241
376
|
value: new Impl.implementation(constructorArgs, privateData),
|
|
242
377
|
writable: false,
|
|
243
378
|
enumerable: false,
|
|
244
379
|
configurable: true
|
|
245
380
|
});
|
|
381
|
+
|
|
246
382
|
obj[impl][utils.wrapperSymbol] = obj;
|
|
383
|
+
if (Impl.init) {
|
|
384
|
+
Impl.init(obj[impl], privateData);
|
|
385
|
+
}
|
|
386
|
+
return obj;
|
|
247
387
|
},
|
|
248
388
|
interface: URL,
|
|
249
389
|
expose: {
|
|
250
|
-
Window: { URL
|
|
251
|
-
Worker: { URL
|
|
390
|
+
Window: { URL },
|
|
391
|
+
Worker: { URL }
|
|
252
392
|
}
|
|
253
|
-
};
|
|
393
|
+
}; // iface
|
|
254
394
|
module.exports = iface;
|
|
255
395
|
|
|
256
396
|
const Impl = require(".//URL-impl.js");
|
package/lib/URLSearchParams.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const conversions = require("webidl-conversions");
|
|
4
4
|
const utils = require("./utils.js");
|
|
5
|
+
|
|
5
6
|
const impl = utils.implSymbol;
|
|
6
7
|
|
|
7
8
|
const IteratorPrototype = Object.create(utils.IteratorPrototype, {
|
|
@@ -50,6 +51,7 @@ function URLSearchParams() {
|
|
|
50
51
|
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
|
51
52
|
args[i] = arguments[i];
|
|
52
53
|
}
|
|
54
|
+
|
|
53
55
|
if (args[0] !== undefined) {
|
|
54
56
|
if (utils.isObject(args[0])) {
|
|
55
57
|
if (args[0][Symbol.iterator] !== undefined) {
|
|
@@ -76,10 +78,12 @@ function URLSearchParams() {
|
|
|
76
78
|
context:
|
|
77
79
|
"Failed to construct 'URLSearchParams': parameter 1" + " sequence" + "'s element" + "'s element"
|
|
78
80
|
});
|
|
81
|
+
|
|
79
82
|
V.push(nextItem);
|
|
80
83
|
}
|
|
81
84
|
nextItem = V;
|
|
82
85
|
}
|
|
86
|
+
|
|
83
87
|
V.push(nextItem);
|
|
84
88
|
}
|
|
85
89
|
args[0] = V;
|
|
@@ -94,12 +98,15 @@ function URLSearchParams() {
|
|
|
94
98
|
if (desc && desc.enumerable) {
|
|
95
99
|
let typedKey = key;
|
|
96
100
|
let typedValue = args[0][key];
|
|
101
|
+
|
|
97
102
|
typedKey = conversions["USVString"](typedKey, {
|
|
98
103
|
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s key"
|
|
99
104
|
});
|
|
105
|
+
|
|
100
106
|
typedValue = conversions["USVString"](typedValue, {
|
|
101
107
|
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s value"
|
|
102
108
|
});
|
|
109
|
+
|
|
103
110
|
result[typedKey] = typedValue;
|
|
104
111
|
}
|
|
105
112
|
}
|
|
@@ -116,13 +123,57 @@ function URLSearchParams() {
|
|
|
116
123
|
iface.setup(this, args);
|
|
117
124
|
}
|
|
118
125
|
|
|
126
|
+
Object.defineProperty(URLSearchParams, "prototype", {
|
|
127
|
+
value: URLSearchParams.prototype,
|
|
128
|
+
writable: false,
|
|
129
|
+
enumerable: false,
|
|
130
|
+
configurable: false
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
Object.defineProperty(URLSearchParams.prototype, Symbol.iterator, {
|
|
134
|
+
writable: true,
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true,
|
|
137
|
+
value: function entries() {
|
|
138
|
+
if (!this || !module.exports.is(this)) {
|
|
139
|
+
throw new TypeError("Illegal invocation");
|
|
140
|
+
}
|
|
141
|
+
return module.exports.createDefaultIterator(this, "key+value");
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
URLSearchParams.prototype.forEach = function forEach(callback) {
|
|
145
|
+
if (!this || !module.exports.is(this)) {
|
|
146
|
+
throw new TypeError("Illegal invocation");
|
|
147
|
+
}
|
|
148
|
+
if (arguments.length < 1) {
|
|
149
|
+
throw new TypeError(
|
|
150
|
+
"Failed to execute 'forEach' on 'URLSearchParams': 1 argument required, " + "but only 0 present."
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (typeof callback !== "function") {
|
|
154
|
+
throw new TypeError(
|
|
155
|
+
"Failed to execute 'forEach' on 'URLSearchParams': The callback provided " + "as parameter 1 is not a function."
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
const thisArg = arguments[1];
|
|
159
|
+
let pairs = Array.from(this[impl]);
|
|
160
|
+
let i = 0;
|
|
161
|
+
while (i < pairs.length) {
|
|
162
|
+
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
|
|
163
|
+
callback.call(thisArg, value, key, this);
|
|
164
|
+
pairs = Array.from(this[impl]);
|
|
165
|
+
i++;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
119
168
|
URLSearchParams.prototype.append = function append(name, value) {
|
|
120
169
|
if (!this || !module.exports.is(this)) {
|
|
121
170
|
throw new TypeError("Illegal invocation");
|
|
122
171
|
}
|
|
172
|
+
|
|
123
173
|
if (arguments.length < 2) {
|
|
124
174
|
throw new TypeError(
|
|
125
|
-
"Failed to execute 'append' on 'URLSearchParams': 2
|
|
175
|
+
"Failed to execute 'append' on 'URLSearchParams': 2 " +
|
|
176
|
+
"arguments required, but only " +
|
|
126
177
|
arguments.length +
|
|
127
178
|
" present."
|
|
128
179
|
);
|
|
@@ -132,12 +183,15 @@ URLSearchParams.prototype.append = function append(name, value) {
|
|
|
132
183
|
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
|
133
184
|
args[i] = arguments[i];
|
|
134
185
|
}
|
|
186
|
+
|
|
135
187
|
args[0] = conversions["USVString"](args[0], {
|
|
136
188
|
context: "Failed to execute 'append' on 'URLSearchParams': parameter 1"
|
|
137
189
|
});
|
|
190
|
+
|
|
138
191
|
args[1] = conversions["USVString"](args[1], {
|
|
139
192
|
context: "Failed to execute 'append' on 'URLSearchParams': parameter 2"
|
|
140
193
|
});
|
|
194
|
+
|
|
141
195
|
return this[impl].append(...args);
|
|
142
196
|
};
|
|
143
197
|
|
|
@@ -145,9 +199,13 @@ URLSearchParams.prototype.delete = function _(name) {
|
|
|
145
199
|
if (!this || !module.exports.is(this)) {
|
|
146
200
|
throw new TypeError("Illegal invocation");
|
|
147
201
|
}
|
|
202
|
+
|
|
148
203
|
if (arguments.length < 1) {
|
|
149
204
|
throw new TypeError(
|
|
150
|
-
"Failed to execute 'delete' on 'URLSearchParams': 1
|
|
205
|
+
"Failed to execute 'delete' on 'URLSearchParams': 1 " +
|
|
206
|
+
"argument required, but only " +
|
|
207
|
+
arguments.length +
|
|
208
|
+
" present."
|
|
151
209
|
);
|
|
152
210
|
}
|
|
153
211
|
|
|
@@ -155,9 +213,11 @@ URLSearchParams.prototype.delete = function _(name) {
|
|
|
155
213
|
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
|
156
214
|
args[i] = arguments[i];
|
|
157
215
|
}
|
|
216
|
+
|
|
158
217
|
args[0] = conversions["USVString"](args[0], {
|
|
159
218
|
context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1"
|
|
160
219
|
});
|
|
220
|
+
|
|
161
221
|
return this[impl].delete(...args);
|
|
162
222
|
};
|
|
163
223
|
|
|
@@ -165,9 +225,13 @@ URLSearchParams.prototype.get = function get(name) {
|
|
|
165
225
|
if (!this || !module.exports.is(this)) {
|
|
166
226
|
throw new TypeError("Illegal invocation");
|
|
167
227
|
}
|
|
228
|
+
|
|
168
229
|
if (arguments.length < 1) {
|
|
169
230
|
throw new TypeError(
|
|
170
|
-
"Failed to execute 'get' on 'URLSearchParams': 1
|
|
231
|
+
"Failed to execute 'get' on 'URLSearchParams': 1 " +
|
|
232
|
+
"argument required, but only " +
|
|
233
|
+
arguments.length +
|
|
234
|
+
" present."
|
|
171
235
|
);
|
|
172
236
|
}
|
|
173
237
|
|
|
@@ -175,7 +239,9 @@ URLSearchParams.prototype.get = function get(name) {
|
|
|
175
239
|
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
|
176
240
|
args[i] = arguments[i];
|
|
177
241
|
}
|
|
242
|
+
|
|
178
243
|
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'get' on 'URLSearchParams': parameter 1" });
|
|
244
|
+
|
|
179
245
|
return this[impl].get(...args);
|
|
180
246
|
};
|
|
181
247
|
|
|
@@ -183,9 +249,13 @@ URLSearchParams.prototype.getAll = function getAll(name) {
|
|
|
183
249
|
if (!this || !module.exports.is(this)) {
|
|
184
250
|
throw new TypeError("Illegal invocation");
|
|
185
251
|
}
|
|
252
|
+
|
|
186
253
|
if (arguments.length < 1) {
|
|
187
254
|
throw new TypeError(
|
|
188
|
-
"Failed to execute 'getAll' on 'URLSearchParams': 1
|
|
255
|
+
"Failed to execute 'getAll' on 'URLSearchParams': 1 " +
|
|
256
|
+
"argument required, but only " +
|
|
257
|
+
arguments.length +
|
|
258
|
+
" present."
|
|
189
259
|
);
|
|
190
260
|
}
|
|
191
261
|
|
|
@@ -193,9 +263,11 @@ URLSearchParams.prototype.getAll = function getAll(name) {
|
|
|
193
263
|
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
|
194
264
|
args[i] = arguments[i];
|
|
195
265
|
}
|
|
266
|
+
|
|
196
267
|
args[0] = conversions["USVString"](args[0], {
|
|
197
268
|
context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1"
|
|
198
269
|
});
|
|
270
|
+
|
|
199
271
|
return utils.tryWrapperForImpl(this[impl].getAll(...args));
|
|
200
272
|
};
|
|
201
273
|
|
|
@@ -203,9 +275,13 @@ URLSearchParams.prototype.has = function has(name) {
|
|
|
203
275
|
if (!this || !module.exports.is(this)) {
|
|
204
276
|
throw new TypeError("Illegal invocation");
|
|
205
277
|
}
|
|
278
|
+
|
|
206
279
|
if (arguments.length < 1) {
|
|
207
280
|
throw new TypeError(
|
|
208
|
-
"Failed to execute 'has' on 'URLSearchParams': 1
|
|
281
|
+
"Failed to execute 'has' on 'URLSearchParams': 1 " +
|
|
282
|
+
"argument required, but only " +
|
|
283
|
+
arguments.length +
|
|
284
|
+
" present."
|
|
209
285
|
);
|
|
210
286
|
}
|
|
211
287
|
|
|
@@ -213,7 +289,9 @@ URLSearchParams.prototype.has = function has(name) {
|
|
|
213
289
|
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
|
214
290
|
args[i] = arguments[i];
|
|
215
291
|
}
|
|
292
|
+
|
|
216
293
|
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'has' on 'URLSearchParams': parameter 1" });
|
|
294
|
+
|
|
217
295
|
return this[impl].has(...args);
|
|
218
296
|
};
|
|
219
297
|
|
|
@@ -221,9 +299,13 @@ URLSearchParams.prototype.set = function set(name, value) {
|
|
|
221
299
|
if (!this || !module.exports.is(this)) {
|
|
222
300
|
throw new TypeError("Illegal invocation");
|
|
223
301
|
}
|
|
302
|
+
|
|
224
303
|
if (arguments.length < 2) {
|
|
225
304
|
throw new TypeError(
|
|
226
|
-
"Failed to execute 'set' on 'URLSearchParams': 2
|
|
305
|
+
"Failed to execute 'set' on 'URLSearchParams': 2 " +
|
|
306
|
+
"arguments required, but only " +
|
|
307
|
+
arguments.length +
|
|
308
|
+
" present."
|
|
227
309
|
);
|
|
228
310
|
}
|
|
229
311
|
|
|
@@ -231,8 +313,11 @@ URLSearchParams.prototype.set = function set(name, value) {
|
|
|
231
313
|
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
|
232
314
|
args[i] = arguments[i];
|
|
233
315
|
}
|
|
316
|
+
|
|
234
317
|
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'set' on 'URLSearchParams': parameter 1" });
|
|
318
|
+
|
|
235
319
|
args[1] = conversions["USVString"](args[1], { context: "Failed to execute 'set' on 'URLSearchParams': parameter 2" });
|
|
320
|
+
|
|
236
321
|
return this[impl].set(...args);
|
|
237
322
|
};
|
|
238
323
|
|
|
@@ -240,56 +325,33 @@ URLSearchParams.prototype.sort = function sort() {
|
|
|
240
325
|
if (!this || !module.exports.is(this)) {
|
|
241
326
|
throw new TypeError("Illegal invocation");
|
|
242
327
|
}
|
|
328
|
+
|
|
243
329
|
return this[impl].sort();
|
|
244
330
|
};
|
|
245
331
|
|
|
246
|
-
URLSearchParams.prototype
|
|
332
|
+
URLSearchParams.prototype.toString = function toString() {
|
|
247
333
|
if (!this || !module.exports.is(this)) {
|
|
248
334
|
throw new TypeError("Illegal invocation");
|
|
249
335
|
}
|
|
250
|
-
|
|
336
|
+
|
|
337
|
+
return this[impl].toString();
|
|
251
338
|
};
|
|
339
|
+
|
|
252
340
|
URLSearchParams.prototype.entries = URLSearchParams.prototype[Symbol.iterator];
|
|
341
|
+
|
|
253
342
|
URLSearchParams.prototype.keys = function keys() {
|
|
254
343
|
if (!this || !module.exports.is(this)) {
|
|
255
344
|
throw new TypeError("Illegal invocation");
|
|
256
345
|
}
|
|
257
346
|
return module.exports.createDefaultIterator(this, "key");
|
|
258
347
|
};
|
|
348
|
+
|
|
259
349
|
URLSearchParams.prototype.values = function values() {
|
|
260
350
|
if (!this || !module.exports.is(this)) {
|
|
261
351
|
throw new TypeError("Illegal invocation");
|
|
262
352
|
}
|
|
263
353
|
return module.exports.createDefaultIterator(this, "value");
|
|
264
354
|
};
|
|
265
|
-
URLSearchParams.prototype.forEach = function forEach(callback) {
|
|
266
|
-
if (!this || !module.exports.is(this)) {
|
|
267
|
-
throw new TypeError("Illegal invocation");
|
|
268
|
-
}
|
|
269
|
-
if (arguments.length < 1) {
|
|
270
|
-
throw new TypeError("Failed to execute 'forEach' on 'URLSearchParams': 1 argument required, but only 0 present.");
|
|
271
|
-
}
|
|
272
|
-
if (typeof callback !== "function") {
|
|
273
|
-
throw new TypeError(
|
|
274
|
-
"Failed to execute 'forEach' on 'URLSearchParams': The callback provided as parameter 1 is not a function."
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
const thisArg = arguments[1];
|
|
278
|
-
let pairs = Array.from(this[impl]);
|
|
279
|
-
let i = 0;
|
|
280
|
-
while (i < pairs.length) {
|
|
281
|
-
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
|
|
282
|
-
callback.call(thisArg, value, key, this);
|
|
283
|
-
pairs = Array.from(this[impl]);
|
|
284
|
-
i++;
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
URLSearchParams.prototype.toString = function toString() {
|
|
288
|
-
if (!this || !module.exports.is(this)) {
|
|
289
|
-
throw new TypeError("Illegal invocation");
|
|
290
|
-
}
|
|
291
|
-
return utils.tryWrapperForImpl(this[impl].toString());
|
|
292
|
-
};
|
|
293
355
|
|
|
294
356
|
Object.defineProperty(URLSearchParams.prototype, Symbol.toStringTag, {
|
|
295
357
|
value: "URLSearchParams",
|
|
@@ -334,6 +396,7 @@ const iface = {
|
|
|
334
396
|
}
|
|
335
397
|
throw new TypeError(`${context} is not of type 'URLSearchParams'.`);
|
|
336
398
|
},
|
|
399
|
+
|
|
337
400
|
createDefaultIterator(target, kind) {
|
|
338
401
|
const iterator = Object.create(IteratorPrototype);
|
|
339
402
|
Object.defineProperty(iterator, utils.iterInternalSymbol, {
|
|
@@ -344,37 +407,43 @@ const iface = {
|
|
|
344
407
|
});
|
|
345
408
|
return iterator;
|
|
346
409
|
},
|
|
410
|
+
|
|
347
411
|
create(constructorArgs, privateData) {
|
|
348
412
|
let obj = Object.create(URLSearchParams.prototype);
|
|
349
|
-
this.setup(obj, constructorArgs, privateData);
|
|
413
|
+
obj = this.setup(obj, constructorArgs, privateData);
|
|
350
414
|
return obj;
|
|
351
415
|
},
|
|
352
416
|
createImpl(constructorArgs, privateData) {
|
|
353
417
|
let obj = Object.create(URLSearchParams.prototype);
|
|
354
|
-
this.setup(obj, constructorArgs, privateData);
|
|
418
|
+
obj = this.setup(obj, constructorArgs, privateData);
|
|
355
419
|
return utils.implForWrapper(obj);
|
|
356
420
|
},
|
|
357
421
|
_internalSetup(obj) {},
|
|
358
422
|
setup(obj, constructorArgs, privateData) {
|
|
359
423
|
if (!privateData) privateData = {};
|
|
424
|
+
|
|
360
425
|
privateData.wrapper = obj;
|
|
361
426
|
|
|
362
427
|
this._internalSetup(obj);
|
|
363
|
-
|
|
364
428
|
Object.defineProperty(obj, impl, {
|
|
365
429
|
value: new Impl.implementation(constructorArgs, privateData),
|
|
366
430
|
writable: false,
|
|
367
431
|
enumerable: false,
|
|
368
432
|
configurable: true
|
|
369
433
|
});
|
|
434
|
+
|
|
370
435
|
obj[impl][utils.wrapperSymbol] = obj;
|
|
436
|
+
if (Impl.init) {
|
|
437
|
+
Impl.init(obj[impl], privateData);
|
|
438
|
+
}
|
|
439
|
+
return obj;
|
|
371
440
|
},
|
|
372
441
|
interface: URLSearchParams,
|
|
373
442
|
expose: {
|
|
374
|
-
Window: { URLSearchParams
|
|
375
|
-
Worker: { URLSearchParams
|
|
443
|
+
Window: { URLSearchParams },
|
|
444
|
+
Worker: { URLSearchParams }
|
|
376
445
|
}
|
|
377
|
-
};
|
|
446
|
+
}; // iface
|
|
378
447
|
module.exports = iface;
|
|
379
448
|
|
|
380
449
|
const Impl = require(".//URLSearchParams-impl.js");
|
package/lib/url-state-machine.js
CHANGED
|
@@ -124,7 +124,14 @@ function parseIPv4Number(input) {
|
|
|
124
124
|
return 0;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
let regex = /[^0-7]/;
|
|
128
|
+
if (R === 10) {
|
|
129
|
+
regex = /[^0-9]/;
|
|
130
|
+
}
|
|
131
|
+
if (R === 16) {
|
|
132
|
+
regex = /[^0-9A-Fa-f]/;
|
|
133
|
+
}
|
|
134
|
+
|
|
128
135
|
if (regex.test(input)) {
|
|
129
136
|
return failure;
|
|
130
137
|
}
|
|
@@ -466,7 +473,7 @@ function trimTabAndNewline(url) {
|
|
|
466
473
|
}
|
|
467
474
|
|
|
468
475
|
function shortenPath(url) {
|
|
469
|
-
const path = url
|
|
476
|
+
const { path } = url;
|
|
470
477
|
if (path.length === 0) {
|
|
471
478
|
return;
|
|
472
479
|
}
|
package/lib/urlencoded.js
CHANGED
|
@@ -84,10 +84,10 @@ function serializeUrlencodedByte(input) {
|
|
|
84
84
|
} else if (byte === 42 ||
|
|
85
85
|
byte === 45 ||
|
|
86
86
|
byte === 46 ||
|
|
87
|
-
byte >= 48 && byte <= 57 ||
|
|
88
|
-
byte >= 65 && byte <= 90 ||
|
|
87
|
+
(byte >= 48 && byte <= 57) ||
|
|
88
|
+
(byte >= 65 && byte <= 90) ||
|
|
89
89
|
byte === 95 ||
|
|
90
|
-
byte >= 97 && byte <= 122) {
|
|
90
|
+
(byte >= 97 && byte <= 122)) {
|
|
91
91
|
output += String.fromCodePoint(byte);
|
|
92
92
|
} else {
|
|
93
93
|
output += percentEncode(byte);
|
package/lib/utils.js
CHANGED
|
@@ -13,7 +13,7 @@ function getReferenceToBytes(bufferSource) {
|
|
|
13
13
|
if (bufferSource instanceof ArrayBuffer) {
|
|
14
14
|
return Buffer.from(bufferSource);
|
|
15
15
|
}
|
|
16
|
-
return Buffer.from(bufferSource.buffer, bufferSource.byteOffset, bufferSource.byteLength)
|
|
16
|
+
return Buffer.from(bufferSource.buffer, bufferSource.byteOffset, bufferSource.byteLength);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function getCopyToBytes(bufferSource) {
|
|
@@ -44,30 +44,58 @@ function getSameObject(wrapper, prop, creator) {
|
|
|
44
44
|
return wrapper[sameObjectCaches][prop];
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
wrapper[sameObjectCaches][prop] = creator();
|
|
48
|
+
return wrapper[sameObjectCaches][prop];
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
function wrapperForImpl(impl) {
|
|
51
52
|
return impl ? impl[wrapperSymbol] : null;
|
|
52
|
-
}
|
|
53
|
+
}
|
|
53
54
|
|
|
54
55
|
function implForWrapper(wrapper) {
|
|
55
56
|
return wrapper ? wrapper[implSymbol] : null;
|
|
56
|
-
}
|
|
57
|
+
}
|
|
57
58
|
|
|
58
59
|
function tryWrapperForImpl(impl) {
|
|
59
60
|
const wrapper = wrapperForImpl(impl);
|
|
60
61
|
return wrapper ? wrapper : impl;
|
|
61
|
-
}
|
|
62
|
+
}
|
|
62
63
|
|
|
63
64
|
function tryImplForWrapper(wrapper) {
|
|
64
65
|
const impl = implForWrapper(wrapper);
|
|
65
66
|
return impl ? impl : wrapper;
|
|
66
|
-
}
|
|
67
|
+
}
|
|
67
68
|
|
|
68
69
|
const iterInternalSymbol = Symbol("internal");
|
|
69
70
|
const IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
|
|
70
71
|
|
|
72
|
+
function isArrayIndexPropName(P) {
|
|
73
|
+
if (typeof P !== "string") {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const i = P >>> 0;
|
|
77
|
+
if (i === Math.pow(2, 32) - 1) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const s = `${i}`;
|
|
81
|
+
if (P !== s) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const supportsPropertyIndex = Symbol("supports property index");
|
|
88
|
+
const supportedPropertyIndices = Symbol("supported property indices");
|
|
89
|
+
const supportsPropertyName = Symbol("supports property name");
|
|
90
|
+
const supportedPropertyNames = Symbol("supported property names");
|
|
91
|
+
const indexedGet = Symbol("indexed property get");
|
|
92
|
+
const indexedSetNew = Symbol("indexed property set new");
|
|
93
|
+
const indexedSetExisting = Symbol("indexed property set existing");
|
|
94
|
+
const namedGet = Symbol("named property get");
|
|
95
|
+
const namedSetNew = Symbol("named property set new");
|
|
96
|
+
const namedSetExisting = Symbol("named property set existing");
|
|
97
|
+
const namedDelete = Symbol("named property delete");
|
|
98
|
+
|
|
71
99
|
module.exports = exports = {
|
|
72
100
|
isObject,
|
|
73
101
|
getReferenceToBytes,
|
|
@@ -81,5 +109,17 @@ module.exports = exports = {
|
|
|
81
109
|
tryWrapperForImpl,
|
|
82
110
|
tryImplForWrapper,
|
|
83
111
|
iterInternalSymbol,
|
|
84
|
-
IteratorPrototype
|
|
112
|
+
IteratorPrototype,
|
|
113
|
+
isArrayIndexPropName,
|
|
114
|
+
supportsPropertyIndex,
|
|
115
|
+
supportedPropertyIndices,
|
|
116
|
+
supportsPropertyName,
|
|
117
|
+
supportedPropertyNames,
|
|
118
|
+
indexedGet,
|
|
119
|
+
indexedSetNew,
|
|
120
|
+
indexedSetExisting,
|
|
121
|
+
namedGet,
|
|
122
|
+
namedSetNew,
|
|
123
|
+
namedSetExisting,
|
|
124
|
+
namedDelete
|
|
85
125
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whatwg-url",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.1",
|
|
4
4
|
"description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery",
|
|
5
5
|
"main": "lib/public-api.js",
|
|
6
6
|
"files": [
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
"repository": "jsdom/whatwg-url",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"lodash.sortby": "^4.7.0",
|
|
14
|
-
"tr46": "^1.0.
|
|
15
|
-
"webidl-conversions": "^4.0.
|
|
14
|
+
"tr46": "^1.0.1",
|
|
15
|
+
"webidl-conversions": "^4.0.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"domexception": "^1.0.
|
|
19
|
-
"eslint": "^4.
|
|
20
|
-
"istanbul": "~0.4.
|
|
21
|
-
"jest": "^
|
|
22
|
-
"jsdom": "^11.
|
|
23
|
-
"recast": "~0.
|
|
24
|
-
"request": "^2.
|
|
25
|
-
"webidl2js": "^7.
|
|
18
|
+
"domexception": "^1.0.1",
|
|
19
|
+
"eslint": "^4.19.1",
|
|
20
|
+
"istanbul": "~0.4.5",
|
|
21
|
+
"jest": "^22.4.3",
|
|
22
|
+
"jsdom": "^11.8.0",
|
|
23
|
+
"recast": "~0.14.7",
|
|
24
|
+
"request": "^2.85.0",
|
|
25
|
+
"webidl2js": "^7.4.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "node scripts/transform.js && node scripts/convert-idl.js",
|