typeson-registry 13.0.1 → 13.2.0
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 +6 -8
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -4
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.cjs +220 -124
- package/dist/index.umd.cjs.map +1 -1
- package/dist/index.umd.min.cjs +2 -2
- package/dist/index.umd.min.cjs.map +1 -1
- package/dist/polyfills/createObjectURL.d.ts.map +1 -1
- package/dist/presets/builtin.umd.cjs +1 -1
- package/dist/presets/builtin.umd.cjs.map +1 -1
- package/dist/presets/postmessage.umd.cjs +1 -1
- package/dist/presets/postmessage.umd.cjs.map +1 -1
- package/dist/presets/socketio.umd.cjs +1 -1
- package/dist/presets/socketio.umd.cjs.map +1 -1
- package/dist/presets/structured-cloning-throwing.umd.cjs +1 -1
- package/dist/presets/structured-cloning-throwing.umd.cjs.map +1 -1
- package/dist/presets/structured-cloning.d.ts.map +1 -1
- package/dist/presets/structured-cloning.umd.cjs +1 -1
- package/dist/presets/structured-cloning.umd.cjs.map +1 -1
- package/dist/presets/undef.umd.cjs +1 -1
- package/dist/presets/undef.umd.cjs.map +1 -1
- package/dist/presets/universal.umd.cjs +1 -1
- package/dist/presets/universal.umd.cjs.map +1 -1
- package/dist/types/arraybuffer.umd.cjs +1 -1
- package/dist/types/arraybuffer.umd.cjs.map +1 -1
- package/dist/types/audiodata.d.ts +6 -0
- package/dist/types/audiodata.d.ts.map +1 -0
- package/dist/types/audiodata.umd.cjs +2 -0
- package/dist/types/audiodata.umd.cjs.map +1 -0
- package/dist/types/bigint-object.umd.cjs +1 -1
- package/dist/types/bigint-object.umd.cjs.map +1 -1
- package/dist/types/blob.umd.cjs +1 -1
- package/dist/types/blob.umd.cjs.map +1 -1
- package/dist/types/cryptokey.umd.cjs +1 -1
- package/dist/types/cryptokey.umd.cjs.map +1 -1
- package/dist/types/dataview.umd.cjs +1 -1
- package/dist/types/dataview.umd.cjs.map +1 -1
- package/dist/types/date.umd.cjs +1 -1
- package/dist/types/date.umd.cjs.map +1 -1
- package/dist/types/domexception.umd.cjs +1 -1
- package/dist/types/domexception.umd.cjs.map +1 -1
- package/dist/types/dommatrix.umd.cjs +1 -1
- package/dist/types/dommatrix.umd.cjs.map +1 -1
- package/dist/types/dompoint.umd.cjs +1 -1
- package/dist/types/dompoint.umd.cjs.map +1 -1
- package/dist/types/domquad.umd.cjs +1 -1
- package/dist/types/domquad.umd.cjs.map +1 -1
- package/dist/types/domrect.umd.cjs +1 -1
- package/dist/types/domrect.umd.cjs.map +1 -1
- package/dist/types/error.umd.cjs +1 -1
- package/dist/types/error.umd.cjs.map +1 -1
- package/dist/types/errors.umd.cjs +1 -1
- package/dist/types/errors.umd.cjs.map +1 -1
- package/dist/types/file.umd.cjs +1 -1
- package/dist/types/file.umd.cjs.map +1 -1
- package/dist/types/filelist.umd.cjs +1 -1
- package/dist/types/filelist.umd.cjs.map +1 -1
- package/dist/types/imagebitmap.umd.cjs +1 -1
- package/dist/types/imagebitmap.umd.cjs.map +1 -1
- package/dist/types/imagedata.umd.cjs +1 -1
- package/dist/types/imagedata.umd.cjs.map +1 -1
- package/dist/types/intl-types.umd.cjs +1 -1
- package/dist/types/intl-types.umd.cjs.map +1 -1
- package/dist/types/map.umd.cjs +1 -1
- package/dist/types/map.umd.cjs.map +1 -1
- package/dist/types/nonbuiltin-ignore.umd.cjs +1 -1
- package/dist/types/nonbuiltin-ignore.umd.cjs.map +1 -1
- package/dist/types/primitive-objects.umd.cjs +1 -1
- package/dist/types/primitive-objects.umd.cjs.map +1 -1
- package/dist/types/promise.umd.cjs +1 -1
- package/dist/types/promise.umd.cjs.map +1 -1
- package/dist/types/regexp.umd.cjs +1 -1
- package/dist/types/regexp.umd.cjs.map +1 -1
- package/dist/types/set.umd.cjs +1 -1
- package/dist/types/set.umd.cjs.map +1 -1
- package/dist/types/typed-arrays-socketio.umd.cjs +1 -1
- package/dist/types/typed-arrays-socketio.umd.cjs.map +1 -1
- package/dist/types/typed-arrays.umd.cjs +1 -1
- package/dist/types/typed-arrays.umd.cjs.map +1 -1
- package/dist/types/undef.umd.cjs +1 -1
- package/dist/types/undef.umd.cjs.map +1 -1
- package/dist/types/user-object.umd.cjs +1 -1
- package/dist/types/user-object.umd.cjs.map +1 -1
- package/package.json +11 -12
- package/polyfills/createObjectURL.cjs +3231 -0
- package/polyfills/createObjectURL.cjs.map +1 -0
- package/polyfills/createObjectURL.js +4 -4
- package/polyfills/createObjectURL.umd.cjs +0 -4
- package/polyfills/createObjectURL.umd.cjs.map +0 -1
|
@@ -0,0 +1,3231 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_module = require('node:module');
|
|
4
|
+
|
|
5
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
|
+
function getDefaultExportFromCjs (x) {
|
|
7
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getAugmentedNamespace(n) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
12
|
+
var f = n.default;
|
|
13
|
+
if (typeof f == "function") {
|
|
14
|
+
var a = function a () {
|
|
15
|
+
var isInstance = false;
|
|
16
|
+
try {
|
|
17
|
+
isInstance = this instanceof a;
|
|
18
|
+
} catch (e) {}
|
|
19
|
+
if (isInstance) {
|
|
20
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
21
|
+
}
|
|
22
|
+
return f.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
a.prototype = f.prototype;
|
|
25
|
+
} else a = {};
|
|
26
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
27
|
+
Object.keys(n).forEach(function (k) {
|
|
28
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
29
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return n[k];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return a;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var whatwgUrl = {};
|
|
40
|
+
|
|
41
|
+
var webidl2jsWrapper = {};
|
|
42
|
+
|
|
43
|
+
function _arrayLikeToArray(r, a) {
|
|
44
|
+
(null == a || a > r.length) && (a = r.length);
|
|
45
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
function _arrayWithHoles(r) {
|
|
49
|
+
if (Array.isArray(r)) return r;
|
|
50
|
+
}
|
|
51
|
+
function _arrayWithoutHoles(r) {
|
|
52
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
53
|
+
}
|
|
54
|
+
function _classCallCheck(a, n) {
|
|
55
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
56
|
+
}
|
|
57
|
+
function _defineProperties(e, r) {
|
|
58
|
+
for (var t = 0; t < r.length; t++) {
|
|
59
|
+
var o = r[t];
|
|
60
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function _createClass(e, r, t) {
|
|
64
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
65
|
+
writable: false
|
|
66
|
+
}), e;
|
|
67
|
+
}
|
|
68
|
+
function _createForOfIteratorHelper(r, e) {
|
|
69
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
70
|
+
if (!t) {
|
|
71
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
72
|
+
t && (r = t);
|
|
73
|
+
var n = 0,
|
|
74
|
+
F = function () {};
|
|
75
|
+
return {
|
|
76
|
+
s: F,
|
|
77
|
+
n: function () {
|
|
78
|
+
return n >= r.length ? {
|
|
79
|
+
done: true
|
|
80
|
+
} : {
|
|
81
|
+
done: false,
|
|
82
|
+
value: r[n++]
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
e: function (r) {
|
|
86
|
+
throw r;
|
|
87
|
+
},
|
|
88
|
+
f: F
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
92
|
+
}
|
|
93
|
+
var o,
|
|
94
|
+
a = true,
|
|
95
|
+
u = false;
|
|
96
|
+
return {
|
|
97
|
+
s: function () {
|
|
98
|
+
t = t.call(r);
|
|
99
|
+
},
|
|
100
|
+
n: function () {
|
|
101
|
+
var r = t.next();
|
|
102
|
+
return a = r.done, r;
|
|
103
|
+
},
|
|
104
|
+
e: function (r) {
|
|
105
|
+
u = true, o = r;
|
|
106
|
+
},
|
|
107
|
+
f: function () {
|
|
108
|
+
try {
|
|
109
|
+
a || null == t.return || t.return();
|
|
110
|
+
} finally {
|
|
111
|
+
if (u) throw o;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function _defineProperty(e, r, t) {
|
|
117
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
118
|
+
value: t,
|
|
119
|
+
enumerable: true,
|
|
120
|
+
configurable: true,
|
|
121
|
+
writable: true
|
|
122
|
+
}) : e[r] = t, e;
|
|
123
|
+
}
|
|
124
|
+
function _iterableToArray(r) {
|
|
125
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
126
|
+
}
|
|
127
|
+
function _iterableToArrayLimit(r, l) {
|
|
128
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
129
|
+
if (null != t) {
|
|
130
|
+
var e,
|
|
131
|
+
n,
|
|
132
|
+
i,
|
|
133
|
+
u,
|
|
134
|
+
a = [],
|
|
135
|
+
f = true,
|
|
136
|
+
o = false;
|
|
137
|
+
try {
|
|
138
|
+
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
139
|
+
} catch (r) {
|
|
140
|
+
o = true, n = r;
|
|
141
|
+
} finally {
|
|
142
|
+
try {
|
|
143
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
144
|
+
} finally {
|
|
145
|
+
if (o) throw n;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return a;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function _nonIterableRest() {
|
|
152
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
153
|
+
}
|
|
154
|
+
function _nonIterableSpread() {
|
|
155
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
156
|
+
}
|
|
157
|
+
function _slicedToArray(r, e) {
|
|
158
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
159
|
+
}
|
|
160
|
+
function _toConsumableArray(r) {
|
|
161
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
162
|
+
}
|
|
163
|
+
function _toPrimitive(t, r) {
|
|
164
|
+
if ("object" != typeof t || !t) return t;
|
|
165
|
+
var e = t[Symbol.toPrimitive];
|
|
166
|
+
if (void 0 !== e) {
|
|
167
|
+
var i = e.call(t, r);
|
|
168
|
+
if ("object" != typeof i) return i;
|
|
169
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
170
|
+
}
|
|
171
|
+
return ("string" === r ? String : Number)(t);
|
|
172
|
+
}
|
|
173
|
+
function _toPropertyKey(t) {
|
|
174
|
+
var i = _toPrimitive(t, "string");
|
|
175
|
+
return "symbol" == typeof i ? i : i + "";
|
|
176
|
+
}
|
|
177
|
+
function _unsupportedIterableToArray(r, a) {
|
|
178
|
+
if (r) {
|
|
179
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
180
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
181
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
var conversions$1 = require("webidl-conversions");
|
|
186
|
+
var utils$1 = require("./utils.js");
|
|
187
|
+
var implSymbol$1 = utils$1.implSymbol;
|
|
188
|
+
var ctorRegistrySymbol$1 = utils$1.ctorRegistrySymbol;
|
|
189
|
+
var interfaceName$1 = "URL";
|
|
190
|
+
exports.is = function (value) {
|
|
191
|
+
return utils$1.isObject(value) && Object.hasOwn(value, implSymbol$1) && value[implSymbol$1] instanceof Impl$1.implementation;
|
|
192
|
+
};
|
|
193
|
+
exports.isImpl = function (value) {
|
|
194
|
+
return utils$1.isObject(value) && value instanceof Impl$1.implementation;
|
|
195
|
+
};
|
|
196
|
+
exports.convert = function (globalObject, value) {
|
|
197
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
198
|
+
_ref$context = _ref.context,
|
|
199
|
+
context = _ref$context === void 0 ? "The provided value" : _ref$context;
|
|
200
|
+
if (exports.is(value)) {
|
|
201
|
+
return utils$1.implForWrapper(value);
|
|
202
|
+
}
|
|
203
|
+
throw new globalObject.TypeError("".concat(context, " is not of type 'URL'."));
|
|
204
|
+
};
|
|
205
|
+
function makeWrapper$1(globalObject, newTarget) {
|
|
206
|
+
var proto;
|
|
207
|
+
if (newTarget !== undefined) {
|
|
208
|
+
proto = newTarget.prototype;
|
|
209
|
+
}
|
|
210
|
+
if (!utils$1.isObject(proto)) {
|
|
211
|
+
proto = globalObject[ctorRegistrySymbol$1]["URL"].prototype;
|
|
212
|
+
}
|
|
213
|
+
return Object.create(proto);
|
|
214
|
+
}
|
|
215
|
+
exports.create = function (globalObject, constructorArgs, privateData) {
|
|
216
|
+
var wrapper = makeWrapper$1(globalObject);
|
|
217
|
+
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
|
218
|
+
};
|
|
219
|
+
exports.createImpl = function (globalObject, constructorArgs, privateData) {
|
|
220
|
+
var wrapper = exports.create(globalObject, constructorArgs, privateData);
|
|
221
|
+
return utils$1.implForWrapper(wrapper);
|
|
222
|
+
};
|
|
223
|
+
exports._internalSetup = function (wrapper, globalObject) {};
|
|
224
|
+
exports.setup = function (wrapper, globalObject) {
|
|
225
|
+
var constructorArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
226
|
+
var privateData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
227
|
+
privateData.wrapper = wrapper;
|
|
228
|
+
exports._internalSetup(wrapper, globalObject);
|
|
229
|
+
Object.defineProperty(wrapper, implSymbol$1, {
|
|
230
|
+
value: new Impl$1.implementation(globalObject, constructorArgs, privateData),
|
|
231
|
+
configurable: true
|
|
232
|
+
});
|
|
233
|
+
wrapper[implSymbol$1][utils$1.wrapperSymbol] = wrapper;
|
|
234
|
+
if (Impl$1.init) {
|
|
235
|
+
Impl$1.init(wrapper[implSymbol$1]);
|
|
236
|
+
}
|
|
237
|
+
return wrapper;
|
|
238
|
+
};
|
|
239
|
+
exports["new"] = function (globalObject, newTarget) {
|
|
240
|
+
var wrapper = makeWrapper$1(globalObject, newTarget);
|
|
241
|
+
exports._internalSetup(wrapper, globalObject);
|
|
242
|
+
Object.defineProperty(wrapper, implSymbol$1, {
|
|
243
|
+
value: Object.create(Impl$1.implementation.prototype),
|
|
244
|
+
configurable: true
|
|
245
|
+
});
|
|
246
|
+
wrapper[implSymbol$1][utils$1.wrapperSymbol] = wrapper;
|
|
247
|
+
if (Impl$1.init) {
|
|
248
|
+
Impl$1.init(wrapper[implSymbol$1]);
|
|
249
|
+
}
|
|
250
|
+
return wrapper[implSymbol$1];
|
|
251
|
+
};
|
|
252
|
+
var exposed$1 = new Set(["Window", "Worker"]);
|
|
253
|
+
exports.install = function (globalObject, globalNames) {
|
|
254
|
+
if (!globalNames.some(function (globalName) {
|
|
255
|
+
return exposed$1.has(globalName);
|
|
256
|
+
})) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
var ctorRegistry = utils$1.initCtorRegistry(globalObject);
|
|
260
|
+
var URL = /*#__PURE__*/function () {
|
|
261
|
+
function URL(url) {
|
|
262
|
+
_classCallCheck(this, URL);
|
|
263
|
+
if (arguments.length < 1) {
|
|
264
|
+
throw new globalObject.TypeError("Failed to construct 'URL': 1 argument required, but only ".concat(arguments.length, " present."));
|
|
265
|
+
}
|
|
266
|
+
var args = [];
|
|
267
|
+
{
|
|
268
|
+
var curArg = arguments[0];
|
|
269
|
+
curArg = conversions$1["USVString"](curArg, {
|
|
270
|
+
context: "Failed to construct 'URL': parameter 1",
|
|
271
|
+
globals: globalObject
|
|
272
|
+
});
|
|
273
|
+
args.push(curArg);
|
|
274
|
+
}
|
|
275
|
+
{
|
|
276
|
+
var _curArg = arguments[1];
|
|
277
|
+
if (_curArg !== undefined) {
|
|
278
|
+
_curArg = conversions$1["USVString"](_curArg, {
|
|
279
|
+
context: "Failed to construct 'URL': parameter 2",
|
|
280
|
+
globals: globalObject
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
args.push(_curArg);
|
|
284
|
+
}
|
|
285
|
+
return exports.setup(Object.create((this instanceof URL ? this.constructor : void 0).prototype), globalObject, args);
|
|
286
|
+
}
|
|
287
|
+
return _createClass(URL, [{
|
|
288
|
+
key: "toJSON",
|
|
289
|
+
value: function toJSON() {
|
|
290
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
291
|
+
if (!exports.is(esValue)) {
|
|
292
|
+
throw new globalObject.TypeError("'toJSON' called on an object that is not a valid instance of URL.");
|
|
293
|
+
}
|
|
294
|
+
return esValue[implSymbol$1].toJSON();
|
|
295
|
+
}
|
|
296
|
+
}, {
|
|
297
|
+
key: "href",
|
|
298
|
+
get: function get() {
|
|
299
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
300
|
+
if (!exports.is(esValue)) {
|
|
301
|
+
throw new globalObject.TypeError("'get href' called on an object that is not a valid instance of URL.");
|
|
302
|
+
}
|
|
303
|
+
return esValue[implSymbol$1]["href"];
|
|
304
|
+
},
|
|
305
|
+
set: function set(V) {
|
|
306
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
307
|
+
if (!exports.is(esValue)) {
|
|
308
|
+
throw new globalObject.TypeError("'set href' called on an object that is not a valid instance of URL.");
|
|
309
|
+
}
|
|
310
|
+
V = conversions$1["USVString"](V, {
|
|
311
|
+
context: "Failed to set the 'href' property on 'URL': The provided value",
|
|
312
|
+
globals: globalObject
|
|
313
|
+
});
|
|
314
|
+
esValue[implSymbol$1]["href"] = V;
|
|
315
|
+
}
|
|
316
|
+
}, {
|
|
317
|
+
key: "toString",
|
|
318
|
+
value: function toString() {
|
|
319
|
+
var esValue = this;
|
|
320
|
+
if (!exports.is(esValue)) {
|
|
321
|
+
throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of URL.");
|
|
322
|
+
}
|
|
323
|
+
return esValue[implSymbol$1]["href"];
|
|
324
|
+
}
|
|
325
|
+
}, {
|
|
326
|
+
key: "origin",
|
|
327
|
+
get: function get() {
|
|
328
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
329
|
+
if (!exports.is(esValue)) {
|
|
330
|
+
throw new globalObject.TypeError("'get origin' called on an object that is not a valid instance of URL.");
|
|
331
|
+
}
|
|
332
|
+
return esValue[implSymbol$1]["origin"];
|
|
333
|
+
}
|
|
334
|
+
}, {
|
|
335
|
+
key: "protocol",
|
|
336
|
+
get: function get() {
|
|
337
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
338
|
+
if (!exports.is(esValue)) {
|
|
339
|
+
throw new globalObject.TypeError("'get protocol' called on an object that is not a valid instance of URL.");
|
|
340
|
+
}
|
|
341
|
+
return esValue[implSymbol$1]["protocol"];
|
|
342
|
+
},
|
|
343
|
+
set: function set(V) {
|
|
344
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
345
|
+
if (!exports.is(esValue)) {
|
|
346
|
+
throw new globalObject.TypeError("'set protocol' called on an object that is not a valid instance of URL.");
|
|
347
|
+
}
|
|
348
|
+
V = conversions$1["USVString"](V, {
|
|
349
|
+
context: "Failed to set the 'protocol' property on 'URL': The provided value",
|
|
350
|
+
globals: globalObject
|
|
351
|
+
});
|
|
352
|
+
esValue[implSymbol$1]["protocol"] = V;
|
|
353
|
+
}
|
|
354
|
+
}, {
|
|
355
|
+
key: "username",
|
|
356
|
+
get: function get() {
|
|
357
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
358
|
+
if (!exports.is(esValue)) {
|
|
359
|
+
throw new globalObject.TypeError("'get username' called on an object that is not a valid instance of URL.");
|
|
360
|
+
}
|
|
361
|
+
return esValue[implSymbol$1]["username"];
|
|
362
|
+
},
|
|
363
|
+
set: function set(V) {
|
|
364
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
365
|
+
if (!exports.is(esValue)) {
|
|
366
|
+
throw new globalObject.TypeError("'set username' called on an object that is not a valid instance of URL.");
|
|
367
|
+
}
|
|
368
|
+
V = conversions$1["USVString"](V, {
|
|
369
|
+
context: "Failed to set the 'username' property on 'URL': The provided value",
|
|
370
|
+
globals: globalObject
|
|
371
|
+
});
|
|
372
|
+
esValue[implSymbol$1]["username"] = V;
|
|
373
|
+
}
|
|
374
|
+
}, {
|
|
375
|
+
key: "password",
|
|
376
|
+
get: function get() {
|
|
377
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
378
|
+
if (!exports.is(esValue)) {
|
|
379
|
+
throw new globalObject.TypeError("'get password' called on an object that is not a valid instance of URL.");
|
|
380
|
+
}
|
|
381
|
+
return esValue[implSymbol$1]["password"];
|
|
382
|
+
},
|
|
383
|
+
set: function set(V) {
|
|
384
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
385
|
+
if (!exports.is(esValue)) {
|
|
386
|
+
throw new globalObject.TypeError("'set password' called on an object that is not a valid instance of URL.");
|
|
387
|
+
}
|
|
388
|
+
V = conversions$1["USVString"](V, {
|
|
389
|
+
context: "Failed to set the 'password' property on 'URL': The provided value",
|
|
390
|
+
globals: globalObject
|
|
391
|
+
});
|
|
392
|
+
esValue[implSymbol$1]["password"] = V;
|
|
393
|
+
}
|
|
394
|
+
}, {
|
|
395
|
+
key: "host",
|
|
396
|
+
get: function get() {
|
|
397
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
398
|
+
if (!exports.is(esValue)) {
|
|
399
|
+
throw new globalObject.TypeError("'get host' called on an object that is not a valid instance of URL.");
|
|
400
|
+
}
|
|
401
|
+
return esValue[implSymbol$1]["host"];
|
|
402
|
+
},
|
|
403
|
+
set: function set(V) {
|
|
404
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
405
|
+
if (!exports.is(esValue)) {
|
|
406
|
+
throw new globalObject.TypeError("'set host' called on an object that is not a valid instance of URL.");
|
|
407
|
+
}
|
|
408
|
+
V = conversions$1["USVString"](V, {
|
|
409
|
+
context: "Failed to set the 'host' property on 'URL': The provided value",
|
|
410
|
+
globals: globalObject
|
|
411
|
+
});
|
|
412
|
+
esValue[implSymbol$1]["host"] = V;
|
|
413
|
+
}
|
|
414
|
+
}, {
|
|
415
|
+
key: "hostname",
|
|
416
|
+
get: function get() {
|
|
417
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
418
|
+
if (!exports.is(esValue)) {
|
|
419
|
+
throw new globalObject.TypeError("'get hostname' called on an object that is not a valid instance of URL.");
|
|
420
|
+
}
|
|
421
|
+
return esValue[implSymbol$1]["hostname"];
|
|
422
|
+
},
|
|
423
|
+
set: function set(V) {
|
|
424
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
425
|
+
if (!exports.is(esValue)) {
|
|
426
|
+
throw new globalObject.TypeError("'set hostname' called on an object that is not a valid instance of URL.");
|
|
427
|
+
}
|
|
428
|
+
V = conversions$1["USVString"](V, {
|
|
429
|
+
context: "Failed to set the 'hostname' property on 'URL': The provided value",
|
|
430
|
+
globals: globalObject
|
|
431
|
+
});
|
|
432
|
+
esValue[implSymbol$1]["hostname"] = V;
|
|
433
|
+
}
|
|
434
|
+
}, {
|
|
435
|
+
key: "port",
|
|
436
|
+
get: function get() {
|
|
437
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
438
|
+
if (!exports.is(esValue)) {
|
|
439
|
+
throw new globalObject.TypeError("'get port' called on an object that is not a valid instance of URL.");
|
|
440
|
+
}
|
|
441
|
+
return esValue[implSymbol$1]["port"];
|
|
442
|
+
},
|
|
443
|
+
set: function set(V) {
|
|
444
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
445
|
+
if (!exports.is(esValue)) {
|
|
446
|
+
throw new globalObject.TypeError("'set port' called on an object that is not a valid instance of URL.");
|
|
447
|
+
}
|
|
448
|
+
V = conversions$1["USVString"](V, {
|
|
449
|
+
context: "Failed to set the 'port' property on 'URL': The provided value",
|
|
450
|
+
globals: globalObject
|
|
451
|
+
});
|
|
452
|
+
esValue[implSymbol$1]["port"] = V;
|
|
453
|
+
}
|
|
454
|
+
}, {
|
|
455
|
+
key: "pathname",
|
|
456
|
+
get: function get() {
|
|
457
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
458
|
+
if (!exports.is(esValue)) {
|
|
459
|
+
throw new globalObject.TypeError("'get pathname' called on an object that is not a valid instance of URL.");
|
|
460
|
+
}
|
|
461
|
+
return esValue[implSymbol$1]["pathname"];
|
|
462
|
+
},
|
|
463
|
+
set: function set(V) {
|
|
464
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
465
|
+
if (!exports.is(esValue)) {
|
|
466
|
+
throw new globalObject.TypeError("'set pathname' called on an object that is not a valid instance of URL.");
|
|
467
|
+
}
|
|
468
|
+
V = conversions$1["USVString"](V, {
|
|
469
|
+
context: "Failed to set the 'pathname' property on 'URL': The provided value",
|
|
470
|
+
globals: globalObject
|
|
471
|
+
});
|
|
472
|
+
esValue[implSymbol$1]["pathname"] = V;
|
|
473
|
+
}
|
|
474
|
+
}, {
|
|
475
|
+
key: "search",
|
|
476
|
+
get: function get() {
|
|
477
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
478
|
+
if (!exports.is(esValue)) {
|
|
479
|
+
throw new globalObject.TypeError("'get search' called on an object that is not a valid instance of URL.");
|
|
480
|
+
}
|
|
481
|
+
return esValue[implSymbol$1]["search"];
|
|
482
|
+
},
|
|
483
|
+
set: function set(V) {
|
|
484
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
485
|
+
if (!exports.is(esValue)) {
|
|
486
|
+
throw new globalObject.TypeError("'set search' called on an object that is not a valid instance of URL.");
|
|
487
|
+
}
|
|
488
|
+
V = conversions$1["USVString"](V, {
|
|
489
|
+
context: "Failed to set the 'search' property on 'URL': The provided value",
|
|
490
|
+
globals: globalObject
|
|
491
|
+
});
|
|
492
|
+
esValue[implSymbol$1]["search"] = V;
|
|
493
|
+
}
|
|
494
|
+
}, {
|
|
495
|
+
key: "searchParams",
|
|
496
|
+
get: function get() {
|
|
497
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
498
|
+
if (!exports.is(esValue)) {
|
|
499
|
+
throw new globalObject.TypeError("'get searchParams' called on an object that is not a valid instance of URL.");
|
|
500
|
+
}
|
|
501
|
+
return utils$1.getSameObject(this, "searchParams", function () {
|
|
502
|
+
return utils$1.tryWrapperForImpl(esValue[implSymbol$1]["searchParams"]);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
}, {
|
|
506
|
+
key: "hash",
|
|
507
|
+
get: function get() {
|
|
508
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
509
|
+
if (!exports.is(esValue)) {
|
|
510
|
+
throw new globalObject.TypeError("'get hash' called on an object that is not a valid instance of URL.");
|
|
511
|
+
}
|
|
512
|
+
return esValue[implSymbol$1]["hash"];
|
|
513
|
+
},
|
|
514
|
+
set: function set(V) {
|
|
515
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
516
|
+
if (!exports.is(esValue)) {
|
|
517
|
+
throw new globalObject.TypeError("'set hash' called on an object that is not a valid instance of URL.");
|
|
518
|
+
}
|
|
519
|
+
V = conversions$1["USVString"](V, {
|
|
520
|
+
context: "Failed to set the 'hash' property on 'URL': The provided value",
|
|
521
|
+
globals: globalObject
|
|
522
|
+
});
|
|
523
|
+
esValue[implSymbol$1]["hash"] = V;
|
|
524
|
+
}
|
|
525
|
+
}], [{
|
|
526
|
+
key: "parse",
|
|
527
|
+
value: function parse(url) {
|
|
528
|
+
var _Impl$implementation;
|
|
529
|
+
if (arguments.length < 1) {
|
|
530
|
+
throw new globalObject.TypeError("Failed to execute 'parse' on 'URL': 1 argument required, but only ".concat(arguments.length, " present."));
|
|
531
|
+
}
|
|
532
|
+
var args = [];
|
|
533
|
+
{
|
|
534
|
+
var curArg = arguments[0];
|
|
535
|
+
curArg = conversions$1["USVString"](curArg, {
|
|
536
|
+
context: "Failed to execute 'parse' on 'URL': parameter 1",
|
|
537
|
+
globals: globalObject
|
|
538
|
+
});
|
|
539
|
+
args.push(curArg);
|
|
540
|
+
}
|
|
541
|
+
{
|
|
542
|
+
var _curArg2 = arguments[1];
|
|
543
|
+
if (_curArg2 !== undefined) {
|
|
544
|
+
_curArg2 = conversions$1["USVString"](_curArg2, {
|
|
545
|
+
context: "Failed to execute 'parse' on 'URL': parameter 2",
|
|
546
|
+
globals: globalObject
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
args.push(_curArg2);
|
|
550
|
+
}
|
|
551
|
+
return utils$1.tryWrapperForImpl((_Impl$implementation = Impl$1.implementation).parse.apply(_Impl$implementation, [globalObject].concat(args)));
|
|
552
|
+
}
|
|
553
|
+
}, {
|
|
554
|
+
key: "canParse",
|
|
555
|
+
value: function canParse(url) {
|
|
556
|
+
var _Impl$implementation2;
|
|
557
|
+
if (arguments.length < 1) {
|
|
558
|
+
throw new globalObject.TypeError("Failed to execute 'canParse' on 'URL': 1 argument required, but only ".concat(arguments.length, " present."));
|
|
559
|
+
}
|
|
560
|
+
var args = [];
|
|
561
|
+
{
|
|
562
|
+
var curArg = arguments[0];
|
|
563
|
+
curArg = conversions$1["USVString"](curArg, {
|
|
564
|
+
context: "Failed to execute 'canParse' on 'URL': parameter 1",
|
|
565
|
+
globals: globalObject
|
|
566
|
+
});
|
|
567
|
+
args.push(curArg);
|
|
568
|
+
}
|
|
569
|
+
{
|
|
570
|
+
var _curArg3 = arguments[1];
|
|
571
|
+
if (_curArg3 !== undefined) {
|
|
572
|
+
_curArg3 = conversions$1["USVString"](_curArg3, {
|
|
573
|
+
context: "Failed to execute 'canParse' on 'URL': parameter 2",
|
|
574
|
+
globals: globalObject
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
args.push(_curArg3);
|
|
578
|
+
}
|
|
579
|
+
return (_Impl$implementation2 = Impl$1.implementation).canParse.apply(_Impl$implementation2, args);
|
|
580
|
+
}
|
|
581
|
+
}]);
|
|
582
|
+
}();
|
|
583
|
+
Object.defineProperties(URL.prototype, _defineProperty({
|
|
584
|
+
toJSON: {
|
|
585
|
+
enumerable: true
|
|
586
|
+
},
|
|
587
|
+
href: {
|
|
588
|
+
enumerable: true
|
|
589
|
+
},
|
|
590
|
+
toString: {
|
|
591
|
+
enumerable: true
|
|
592
|
+
},
|
|
593
|
+
origin: {
|
|
594
|
+
enumerable: true
|
|
595
|
+
},
|
|
596
|
+
protocol: {
|
|
597
|
+
enumerable: true
|
|
598
|
+
},
|
|
599
|
+
username: {
|
|
600
|
+
enumerable: true
|
|
601
|
+
},
|
|
602
|
+
password: {
|
|
603
|
+
enumerable: true
|
|
604
|
+
},
|
|
605
|
+
host: {
|
|
606
|
+
enumerable: true
|
|
607
|
+
},
|
|
608
|
+
hostname: {
|
|
609
|
+
enumerable: true
|
|
610
|
+
},
|
|
611
|
+
port: {
|
|
612
|
+
enumerable: true
|
|
613
|
+
},
|
|
614
|
+
pathname: {
|
|
615
|
+
enumerable: true
|
|
616
|
+
},
|
|
617
|
+
search: {
|
|
618
|
+
enumerable: true
|
|
619
|
+
},
|
|
620
|
+
searchParams: {
|
|
621
|
+
enumerable: true
|
|
622
|
+
},
|
|
623
|
+
hash: {
|
|
624
|
+
enumerable: true
|
|
625
|
+
}
|
|
626
|
+
}, Symbol.toStringTag, {
|
|
627
|
+
value: "URL",
|
|
628
|
+
configurable: true
|
|
629
|
+
}));
|
|
630
|
+
Object.defineProperties(URL, {
|
|
631
|
+
parse: {
|
|
632
|
+
enumerable: true
|
|
633
|
+
},
|
|
634
|
+
canParse: {
|
|
635
|
+
enumerable: true
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
ctorRegistry[interfaceName$1] = URL;
|
|
639
|
+
Object.defineProperty(globalObject, interfaceName$1, {
|
|
640
|
+
configurable: true,
|
|
641
|
+
writable: true,
|
|
642
|
+
value: URL
|
|
643
|
+
});
|
|
644
|
+
if (globalNames.includes("Window")) {
|
|
645
|
+
Object.defineProperty(globalObject, "webkitURL", {
|
|
646
|
+
configurable: true,
|
|
647
|
+
writable: true,
|
|
648
|
+
value: URL
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
var Impl$1 = require("./URL-impl.js");
|
|
653
|
+
|
|
654
|
+
var URL$1 = /*#__PURE__*/Object.freeze({
|
|
655
|
+
__proto__: null
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
var require$$0 = /*@__PURE__*/getAugmentedNamespace(URL$1);
|
|
659
|
+
|
|
660
|
+
var conversions = require("webidl-conversions");
|
|
661
|
+
var utils = require("./utils.js");
|
|
662
|
+
var Function = require("./Function.js");
|
|
663
|
+
var newObjectInRealm = utils.newObjectInRealm;
|
|
664
|
+
var implSymbol = utils.implSymbol;
|
|
665
|
+
var ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
|
666
|
+
var interfaceName = "URLSearchParams";
|
|
667
|
+
exports.is = function (value) {
|
|
668
|
+
return utils.isObject(value) && Object.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
|
669
|
+
};
|
|
670
|
+
exports.isImpl = function (value) {
|
|
671
|
+
return utils.isObject(value) && value instanceof Impl.implementation;
|
|
672
|
+
};
|
|
673
|
+
exports.convert = function (globalObject, value) {
|
|
674
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
675
|
+
_ref$context = _ref.context,
|
|
676
|
+
context = _ref$context === void 0 ? "The provided value" : _ref$context;
|
|
677
|
+
if (exports.is(value)) {
|
|
678
|
+
return utils.implForWrapper(value);
|
|
679
|
+
}
|
|
680
|
+
throw new globalObject.TypeError("".concat(context, " is not of type 'URLSearchParams'."));
|
|
681
|
+
};
|
|
682
|
+
exports.createDefaultIterator = function (globalObject, target, kind) {
|
|
683
|
+
var ctorRegistry = globalObject[ctorRegistrySymbol];
|
|
684
|
+
var iteratorPrototype = ctorRegistry["URLSearchParams Iterator"];
|
|
685
|
+
var iterator = Object.create(iteratorPrototype);
|
|
686
|
+
Object.defineProperty(iterator, utils.iterInternalSymbol, {
|
|
687
|
+
value: {
|
|
688
|
+
target: target,
|
|
689
|
+
kind: kind,
|
|
690
|
+
index: 0
|
|
691
|
+
},
|
|
692
|
+
configurable: true
|
|
693
|
+
});
|
|
694
|
+
return iterator;
|
|
695
|
+
};
|
|
696
|
+
function makeWrapper(globalObject, newTarget) {
|
|
697
|
+
var proto;
|
|
698
|
+
if (newTarget !== undefined) {
|
|
699
|
+
proto = newTarget.prototype;
|
|
700
|
+
}
|
|
701
|
+
if (!utils.isObject(proto)) {
|
|
702
|
+
proto = globalObject[ctorRegistrySymbol]["URLSearchParams"].prototype;
|
|
703
|
+
}
|
|
704
|
+
return Object.create(proto);
|
|
705
|
+
}
|
|
706
|
+
exports.create = function (globalObject, constructorArgs, privateData) {
|
|
707
|
+
var wrapper = makeWrapper(globalObject);
|
|
708
|
+
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
|
709
|
+
};
|
|
710
|
+
exports.createImpl = function (globalObject, constructorArgs, privateData) {
|
|
711
|
+
var wrapper = exports.create(globalObject, constructorArgs, privateData);
|
|
712
|
+
return utils.implForWrapper(wrapper);
|
|
713
|
+
};
|
|
714
|
+
exports._internalSetup = function (wrapper, globalObject) {};
|
|
715
|
+
exports.setup = function (wrapper, globalObject) {
|
|
716
|
+
var constructorArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
717
|
+
var privateData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
718
|
+
privateData.wrapper = wrapper;
|
|
719
|
+
exports._internalSetup(wrapper, globalObject);
|
|
720
|
+
Object.defineProperty(wrapper, implSymbol, {
|
|
721
|
+
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
|
722
|
+
configurable: true
|
|
723
|
+
});
|
|
724
|
+
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
|
725
|
+
if (Impl.init) {
|
|
726
|
+
Impl.init(wrapper[implSymbol]);
|
|
727
|
+
}
|
|
728
|
+
return wrapper;
|
|
729
|
+
};
|
|
730
|
+
exports["new"] = function (globalObject, newTarget) {
|
|
731
|
+
var wrapper = makeWrapper(globalObject, newTarget);
|
|
732
|
+
exports._internalSetup(wrapper, globalObject);
|
|
733
|
+
Object.defineProperty(wrapper, implSymbol, {
|
|
734
|
+
value: Object.create(Impl.implementation.prototype),
|
|
735
|
+
configurable: true
|
|
736
|
+
});
|
|
737
|
+
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
|
738
|
+
if (Impl.init) {
|
|
739
|
+
Impl.init(wrapper[implSymbol]);
|
|
740
|
+
}
|
|
741
|
+
return wrapper[implSymbol];
|
|
742
|
+
};
|
|
743
|
+
var exposed = new Set(["Window", "Worker"]);
|
|
744
|
+
exports.install = function (globalObject, globalNames) {
|
|
745
|
+
if (!globalNames.some(function (globalName) {
|
|
746
|
+
return exposed.has(globalName);
|
|
747
|
+
})) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
var ctorRegistry = utils.initCtorRegistry(globalObject);
|
|
751
|
+
var URLSearchParams = /*#__PURE__*/function () {
|
|
752
|
+
function URLSearchParams() {
|
|
753
|
+
_classCallCheck(this, URLSearchParams);
|
|
754
|
+
var args = [];
|
|
755
|
+
{
|
|
756
|
+
var curArg = arguments[0];
|
|
757
|
+
if (curArg !== undefined) {
|
|
758
|
+
if (utils.isObject(curArg)) {
|
|
759
|
+
if (utils.getMethod(curArg, Symbol.iterator, "Failed to construct 'URLSearchParams': parameter 1") !== undefined) {
|
|
760
|
+
if (!utils.isObject(curArg)) {
|
|
761
|
+
throw new globalObject.TypeError("Failed to construct 'URLSearchParams': parameter 1" + " sequence" + " is not an iterable object.");
|
|
762
|
+
} else {
|
|
763
|
+
var V = [];
|
|
764
|
+
var tmp = curArg;
|
|
765
|
+
var _iterator = _createForOfIteratorHelper(tmp),
|
|
766
|
+
_step;
|
|
767
|
+
try {
|
|
768
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
769
|
+
var nextItem = _step.value;
|
|
770
|
+
if (!utils.isObject(nextItem)) {
|
|
771
|
+
throw new globalObject.TypeError("Failed to construct 'URLSearchParams': parameter 1" + " sequence" + "'s element" + " is not an iterable object.");
|
|
772
|
+
} else {
|
|
773
|
+
var _V = [];
|
|
774
|
+
var _tmp = nextItem;
|
|
775
|
+
var _iterator2 = _createForOfIteratorHelper(_tmp),
|
|
776
|
+
_step2;
|
|
777
|
+
try {
|
|
778
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
779
|
+
var _nextItem = _step2.value;
|
|
780
|
+
_nextItem = conversions["USVString"](_nextItem, {
|
|
781
|
+
context: "Failed to construct 'URLSearchParams': parameter 1" + " sequence" + "'s element" + "'s element",
|
|
782
|
+
globals: globalObject
|
|
783
|
+
});
|
|
784
|
+
_V.push(_nextItem);
|
|
785
|
+
}
|
|
786
|
+
} catch (err) {
|
|
787
|
+
_iterator2.e(err);
|
|
788
|
+
} finally {
|
|
789
|
+
_iterator2.f();
|
|
790
|
+
}
|
|
791
|
+
nextItem = _V;
|
|
792
|
+
}
|
|
793
|
+
V.push(nextItem);
|
|
794
|
+
}
|
|
795
|
+
} catch (err) {
|
|
796
|
+
_iterator.e(err);
|
|
797
|
+
} finally {
|
|
798
|
+
_iterator.f();
|
|
799
|
+
}
|
|
800
|
+
curArg = V;
|
|
801
|
+
}
|
|
802
|
+
} else {
|
|
803
|
+
if (!utils.isObject(curArg)) {
|
|
804
|
+
throw new globalObject.TypeError("Failed to construct 'URLSearchParams': parameter 1" + " record" + " is not an object.");
|
|
805
|
+
} else {
|
|
806
|
+
var result = Object.create(null);
|
|
807
|
+
var _iterator3 = _createForOfIteratorHelper(Reflect.ownKeys(curArg)),
|
|
808
|
+
_step3;
|
|
809
|
+
try {
|
|
810
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
811
|
+
var key = _step3.value;
|
|
812
|
+
var desc = Object.getOwnPropertyDescriptor(curArg, key);
|
|
813
|
+
if (desc && desc.enumerable) {
|
|
814
|
+
var typedKey = key;
|
|
815
|
+
typedKey = conversions["USVString"](typedKey, {
|
|
816
|
+
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s key",
|
|
817
|
+
globals: globalObject
|
|
818
|
+
});
|
|
819
|
+
var typedValue = curArg[key];
|
|
820
|
+
typedValue = conversions["USVString"](typedValue, {
|
|
821
|
+
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s value",
|
|
822
|
+
globals: globalObject
|
|
823
|
+
});
|
|
824
|
+
result[typedKey] = typedValue;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
} catch (err) {
|
|
828
|
+
_iterator3.e(err);
|
|
829
|
+
} finally {
|
|
830
|
+
_iterator3.f();
|
|
831
|
+
}
|
|
832
|
+
curArg = result;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
} else {
|
|
836
|
+
curArg = conversions["USVString"](curArg, {
|
|
837
|
+
context: "Failed to construct 'URLSearchParams': parameter 1",
|
|
838
|
+
globals: globalObject
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
} else {
|
|
842
|
+
curArg = "";
|
|
843
|
+
}
|
|
844
|
+
args.push(curArg);
|
|
845
|
+
}
|
|
846
|
+
return exports.setup(Object.create((this instanceof URLSearchParams ? this.constructor : void 0).prototype), globalObject, args);
|
|
847
|
+
}
|
|
848
|
+
return _createClass(URLSearchParams, [{
|
|
849
|
+
key: "append",
|
|
850
|
+
value: function append(name, value) {
|
|
851
|
+
var _esValue$implSymbol;
|
|
852
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
853
|
+
if (!exports.is(esValue)) {
|
|
854
|
+
throw new globalObject.TypeError("'append' called on an object that is not a valid instance of URLSearchParams.");
|
|
855
|
+
}
|
|
856
|
+
if (arguments.length < 2) {
|
|
857
|
+
throw new globalObject.TypeError("Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only ".concat(arguments.length, " present."));
|
|
858
|
+
}
|
|
859
|
+
var args = [];
|
|
860
|
+
{
|
|
861
|
+
var curArg = arguments[0];
|
|
862
|
+
curArg = conversions["USVString"](curArg, {
|
|
863
|
+
context: "Failed to execute 'append' on 'URLSearchParams': parameter 1",
|
|
864
|
+
globals: globalObject
|
|
865
|
+
});
|
|
866
|
+
args.push(curArg);
|
|
867
|
+
}
|
|
868
|
+
{
|
|
869
|
+
var _curArg = arguments[1];
|
|
870
|
+
_curArg = conversions["USVString"](_curArg, {
|
|
871
|
+
context: "Failed to execute 'append' on 'URLSearchParams': parameter 2",
|
|
872
|
+
globals: globalObject
|
|
873
|
+
});
|
|
874
|
+
args.push(_curArg);
|
|
875
|
+
}
|
|
876
|
+
return utils.tryWrapperForImpl((_esValue$implSymbol = esValue[implSymbol]).append.apply(_esValue$implSymbol, args));
|
|
877
|
+
}
|
|
878
|
+
}, {
|
|
879
|
+
key: "delete",
|
|
880
|
+
value: function _delete(name) {
|
|
881
|
+
var _esValue$implSymbol2;
|
|
882
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
883
|
+
if (!exports.is(esValue)) {
|
|
884
|
+
throw new globalObject.TypeError("'delete' called on an object that is not a valid instance of URLSearchParams.");
|
|
885
|
+
}
|
|
886
|
+
if (arguments.length < 1) {
|
|
887
|
+
throw new globalObject.TypeError("Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only ".concat(arguments.length, " present."));
|
|
888
|
+
}
|
|
889
|
+
var args = [];
|
|
890
|
+
{
|
|
891
|
+
var curArg = arguments[0];
|
|
892
|
+
curArg = conversions["USVString"](curArg, {
|
|
893
|
+
context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1",
|
|
894
|
+
globals: globalObject
|
|
895
|
+
});
|
|
896
|
+
args.push(curArg);
|
|
897
|
+
}
|
|
898
|
+
{
|
|
899
|
+
var _curArg2 = arguments[1];
|
|
900
|
+
if (_curArg2 !== undefined) {
|
|
901
|
+
_curArg2 = conversions["USVString"](_curArg2, {
|
|
902
|
+
context: "Failed to execute 'delete' on 'URLSearchParams': parameter 2",
|
|
903
|
+
globals: globalObject
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
args.push(_curArg2);
|
|
907
|
+
}
|
|
908
|
+
return utils.tryWrapperForImpl((_esValue$implSymbol2 = esValue[implSymbol])["delete"].apply(_esValue$implSymbol2, args));
|
|
909
|
+
}
|
|
910
|
+
}, {
|
|
911
|
+
key: "get",
|
|
912
|
+
value: function get(name) {
|
|
913
|
+
var _esValue$implSymbol3;
|
|
914
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
915
|
+
if (!exports.is(esValue)) {
|
|
916
|
+
throw new globalObject.TypeError("'get' called on an object that is not a valid instance of URLSearchParams.");
|
|
917
|
+
}
|
|
918
|
+
if (arguments.length < 1) {
|
|
919
|
+
throw new globalObject.TypeError("Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only ".concat(arguments.length, " present."));
|
|
920
|
+
}
|
|
921
|
+
var args = [];
|
|
922
|
+
{
|
|
923
|
+
var curArg = arguments[0];
|
|
924
|
+
curArg = conversions["USVString"](curArg, {
|
|
925
|
+
context: "Failed to execute 'get' on 'URLSearchParams': parameter 1",
|
|
926
|
+
globals: globalObject
|
|
927
|
+
});
|
|
928
|
+
args.push(curArg);
|
|
929
|
+
}
|
|
930
|
+
return (_esValue$implSymbol3 = esValue[implSymbol]).get.apply(_esValue$implSymbol3, args);
|
|
931
|
+
}
|
|
932
|
+
}, {
|
|
933
|
+
key: "getAll",
|
|
934
|
+
value: function getAll(name) {
|
|
935
|
+
var _esValue$implSymbol4;
|
|
936
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
937
|
+
if (!exports.is(esValue)) {
|
|
938
|
+
throw new globalObject.TypeError("'getAll' called on an object that is not a valid instance of URLSearchParams.");
|
|
939
|
+
}
|
|
940
|
+
if (arguments.length < 1) {
|
|
941
|
+
throw new globalObject.TypeError("Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only ".concat(arguments.length, " present."));
|
|
942
|
+
}
|
|
943
|
+
var args = [];
|
|
944
|
+
{
|
|
945
|
+
var curArg = arguments[0];
|
|
946
|
+
curArg = conversions["USVString"](curArg, {
|
|
947
|
+
context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1",
|
|
948
|
+
globals: globalObject
|
|
949
|
+
});
|
|
950
|
+
args.push(curArg);
|
|
951
|
+
}
|
|
952
|
+
return utils.tryWrapperForImpl((_esValue$implSymbol4 = esValue[implSymbol]).getAll.apply(_esValue$implSymbol4, args));
|
|
953
|
+
}
|
|
954
|
+
}, {
|
|
955
|
+
key: "has",
|
|
956
|
+
value: function has(name) {
|
|
957
|
+
var _esValue$implSymbol5;
|
|
958
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
959
|
+
if (!exports.is(esValue)) {
|
|
960
|
+
throw new globalObject.TypeError("'has' called on an object that is not a valid instance of URLSearchParams.");
|
|
961
|
+
}
|
|
962
|
+
if (arguments.length < 1) {
|
|
963
|
+
throw new globalObject.TypeError("Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only ".concat(arguments.length, " present."));
|
|
964
|
+
}
|
|
965
|
+
var args = [];
|
|
966
|
+
{
|
|
967
|
+
var curArg = arguments[0];
|
|
968
|
+
curArg = conversions["USVString"](curArg, {
|
|
969
|
+
context: "Failed to execute 'has' on 'URLSearchParams': parameter 1",
|
|
970
|
+
globals: globalObject
|
|
971
|
+
});
|
|
972
|
+
args.push(curArg);
|
|
973
|
+
}
|
|
974
|
+
{
|
|
975
|
+
var _curArg3 = arguments[1];
|
|
976
|
+
if (_curArg3 !== undefined) {
|
|
977
|
+
_curArg3 = conversions["USVString"](_curArg3, {
|
|
978
|
+
context: "Failed to execute 'has' on 'URLSearchParams': parameter 2",
|
|
979
|
+
globals: globalObject
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
args.push(_curArg3);
|
|
983
|
+
}
|
|
984
|
+
return (_esValue$implSymbol5 = esValue[implSymbol]).has.apply(_esValue$implSymbol5, args);
|
|
985
|
+
}
|
|
986
|
+
}, {
|
|
987
|
+
key: "set",
|
|
988
|
+
value: function set(name, value) {
|
|
989
|
+
var _esValue$implSymbol6;
|
|
990
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
991
|
+
if (!exports.is(esValue)) {
|
|
992
|
+
throw new globalObject.TypeError("'set' called on an object that is not a valid instance of URLSearchParams.");
|
|
993
|
+
}
|
|
994
|
+
if (arguments.length < 2) {
|
|
995
|
+
throw new globalObject.TypeError("Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only ".concat(arguments.length, " present."));
|
|
996
|
+
}
|
|
997
|
+
var args = [];
|
|
998
|
+
{
|
|
999
|
+
var curArg = arguments[0];
|
|
1000
|
+
curArg = conversions["USVString"](curArg, {
|
|
1001
|
+
context: "Failed to execute 'set' on 'URLSearchParams': parameter 1",
|
|
1002
|
+
globals: globalObject
|
|
1003
|
+
});
|
|
1004
|
+
args.push(curArg);
|
|
1005
|
+
}
|
|
1006
|
+
{
|
|
1007
|
+
var _curArg4 = arguments[1];
|
|
1008
|
+
_curArg4 = conversions["USVString"](_curArg4, {
|
|
1009
|
+
context: "Failed to execute 'set' on 'URLSearchParams': parameter 2",
|
|
1010
|
+
globals: globalObject
|
|
1011
|
+
});
|
|
1012
|
+
args.push(_curArg4);
|
|
1013
|
+
}
|
|
1014
|
+
return utils.tryWrapperForImpl((_esValue$implSymbol6 = esValue[implSymbol]).set.apply(_esValue$implSymbol6, args));
|
|
1015
|
+
}
|
|
1016
|
+
}, {
|
|
1017
|
+
key: "sort",
|
|
1018
|
+
value: function sort() {
|
|
1019
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
1020
|
+
if (!exports.is(esValue)) {
|
|
1021
|
+
throw new globalObject.TypeError("'sort' called on an object that is not a valid instance of URLSearchParams.");
|
|
1022
|
+
}
|
|
1023
|
+
return utils.tryWrapperForImpl(esValue[implSymbol].sort());
|
|
1024
|
+
}
|
|
1025
|
+
}, {
|
|
1026
|
+
key: "toString",
|
|
1027
|
+
value: function toString() {
|
|
1028
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
1029
|
+
if (!exports.is(esValue)) {
|
|
1030
|
+
throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of URLSearchParams.");
|
|
1031
|
+
}
|
|
1032
|
+
return esValue[implSymbol].toString();
|
|
1033
|
+
}
|
|
1034
|
+
}, {
|
|
1035
|
+
key: "keys",
|
|
1036
|
+
value: function keys() {
|
|
1037
|
+
if (!exports.is(this)) {
|
|
1038
|
+
throw new globalObject.TypeError("'keys' called on an object that is not a valid instance of URLSearchParams.");
|
|
1039
|
+
}
|
|
1040
|
+
return exports.createDefaultIterator(globalObject, this, "key");
|
|
1041
|
+
}
|
|
1042
|
+
}, {
|
|
1043
|
+
key: "values",
|
|
1044
|
+
value: function values() {
|
|
1045
|
+
if (!exports.is(this)) {
|
|
1046
|
+
throw new globalObject.TypeError("'values' called on an object that is not a valid instance of URLSearchParams.");
|
|
1047
|
+
}
|
|
1048
|
+
return exports.createDefaultIterator(globalObject, this, "value");
|
|
1049
|
+
}
|
|
1050
|
+
}, {
|
|
1051
|
+
key: "entries",
|
|
1052
|
+
value: function entries() {
|
|
1053
|
+
if (!exports.is(this)) {
|
|
1054
|
+
throw new globalObject.TypeError("'entries' called on an object that is not a valid instance of URLSearchParams.");
|
|
1055
|
+
}
|
|
1056
|
+
return exports.createDefaultIterator(globalObject, this, "key+value");
|
|
1057
|
+
}
|
|
1058
|
+
}, {
|
|
1059
|
+
key: "forEach",
|
|
1060
|
+
value: function forEach(callback) {
|
|
1061
|
+
if (!exports.is(this)) {
|
|
1062
|
+
throw new globalObject.TypeError("'forEach' called on an object that is not a valid instance of URLSearchParams.");
|
|
1063
|
+
}
|
|
1064
|
+
if (arguments.length < 1) {
|
|
1065
|
+
throw new globalObject.TypeError("Failed to execute 'forEach' on 'iterable': 1 argument required, but only 0 present.");
|
|
1066
|
+
}
|
|
1067
|
+
callback = Function.convert(globalObject, callback, {
|
|
1068
|
+
context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1"
|
|
1069
|
+
});
|
|
1070
|
+
var thisArg = arguments[1];
|
|
1071
|
+
var pairs = Array.from(this[implSymbol]);
|
|
1072
|
+
var i = 0;
|
|
1073
|
+
while (i < pairs.length) {
|
|
1074
|
+
var _pairs$i$map = pairs[i].map(utils.tryWrapperForImpl),
|
|
1075
|
+
_pairs$i$map2 = _slicedToArray(_pairs$i$map, 2),
|
|
1076
|
+
key = _pairs$i$map2[0],
|
|
1077
|
+
value = _pairs$i$map2[1];
|
|
1078
|
+
callback.call(thisArg, value, key, this);
|
|
1079
|
+
pairs = Array.from(this[implSymbol]);
|
|
1080
|
+
i++;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}, {
|
|
1084
|
+
key: "size",
|
|
1085
|
+
get: function get() {
|
|
1086
|
+
var esValue = this !== null && this !== undefined ? this : globalObject;
|
|
1087
|
+
if (!exports.is(esValue)) {
|
|
1088
|
+
throw new globalObject.TypeError("'get size' called on an object that is not a valid instance of URLSearchParams.");
|
|
1089
|
+
}
|
|
1090
|
+
return esValue[implSymbol]["size"];
|
|
1091
|
+
}
|
|
1092
|
+
}]);
|
|
1093
|
+
}();
|
|
1094
|
+
Object.defineProperties(URLSearchParams.prototype, _defineProperty(_defineProperty({
|
|
1095
|
+
append: {
|
|
1096
|
+
enumerable: true
|
|
1097
|
+
},
|
|
1098
|
+
"delete": {
|
|
1099
|
+
enumerable: true
|
|
1100
|
+
},
|
|
1101
|
+
get: {
|
|
1102
|
+
enumerable: true
|
|
1103
|
+
},
|
|
1104
|
+
getAll: {
|
|
1105
|
+
enumerable: true
|
|
1106
|
+
},
|
|
1107
|
+
has: {
|
|
1108
|
+
enumerable: true
|
|
1109
|
+
},
|
|
1110
|
+
set: {
|
|
1111
|
+
enumerable: true
|
|
1112
|
+
},
|
|
1113
|
+
sort: {
|
|
1114
|
+
enumerable: true
|
|
1115
|
+
},
|
|
1116
|
+
toString: {
|
|
1117
|
+
enumerable: true
|
|
1118
|
+
},
|
|
1119
|
+
keys: {
|
|
1120
|
+
enumerable: true
|
|
1121
|
+
},
|
|
1122
|
+
values: {
|
|
1123
|
+
enumerable: true
|
|
1124
|
+
},
|
|
1125
|
+
entries: {
|
|
1126
|
+
enumerable: true
|
|
1127
|
+
},
|
|
1128
|
+
forEach: {
|
|
1129
|
+
enumerable: true
|
|
1130
|
+
},
|
|
1131
|
+
size: {
|
|
1132
|
+
enumerable: true
|
|
1133
|
+
}
|
|
1134
|
+
}, Symbol.toStringTag, {
|
|
1135
|
+
value: "URLSearchParams",
|
|
1136
|
+
configurable: true
|
|
1137
|
+
}), Symbol.iterator, {
|
|
1138
|
+
value: URLSearchParams.prototype.entries,
|
|
1139
|
+
configurable: true,
|
|
1140
|
+
writable: true
|
|
1141
|
+
}));
|
|
1142
|
+
ctorRegistry[interfaceName] = URLSearchParams;
|
|
1143
|
+
ctorRegistry["URLSearchParams Iterator"] = Object.create(ctorRegistry["%IteratorPrototype%"], _defineProperty({}, Symbol.toStringTag, {
|
|
1144
|
+
configurable: true,
|
|
1145
|
+
value: "URLSearchParams Iterator"
|
|
1146
|
+
}));
|
|
1147
|
+
utils.define(ctorRegistry["URLSearchParams Iterator"], {
|
|
1148
|
+
next: function next() {
|
|
1149
|
+
var internal = this && this[utils.iterInternalSymbol];
|
|
1150
|
+
if (!internal) {
|
|
1151
|
+
throw new globalObject.TypeError("next() called on a value that is not a URLSearchParams iterator object");
|
|
1152
|
+
}
|
|
1153
|
+
var target = internal.target,
|
|
1154
|
+
kind = internal.kind,
|
|
1155
|
+
index = internal.index;
|
|
1156
|
+
var values = Array.from(target[implSymbol]);
|
|
1157
|
+
var len = values.length;
|
|
1158
|
+
if (index >= len) {
|
|
1159
|
+
return newObjectInRealm(globalObject, {
|
|
1160
|
+
value: undefined,
|
|
1161
|
+
done: true
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
var pair = values[index];
|
|
1165
|
+
internal.index = index + 1;
|
|
1166
|
+
return newObjectInRealm(globalObject, utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind));
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
Object.defineProperty(globalObject, interfaceName, {
|
|
1170
|
+
configurable: true,
|
|
1171
|
+
writable: true,
|
|
1172
|
+
value: URLSearchParams
|
|
1173
|
+
});
|
|
1174
|
+
};
|
|
1175
|
+
var Impl = require("./URLSearchParams-impl.js");
|
|
1176
|
+
|
|
1177
|
+
var URLSearchParams = /*#__PURE__*/Object.freeze({
|
|
1178
|
+
__proto__: null
|
|
1179
|
+
});
|
|
1180
|
+
|
|
1181
|
+
var require$$1$2 = /*@__PURE__*/getAugmentedNamespace(URLSearchParams);
|
|
1182
|
+
|
|
1183
|
+
var hasRequiredWebidl2jsWrapper;
|
|
1184
|
+
|
|
1185
|
+
function requireWebidl2jsWrapper () {
|
|
1186
|
+
if (hasRequiredWebidl2jsWrapper) return webidl2jsWrapper;
|
|
1187
|
+
hasRequiredWebidl2jsWrapper = 1;
|
|
1188
|
+
|
|
1189
|
+
var URL = require$$0;
|
|
1190
|
+
var URLSearchParams = require$$1$2;
|
|
1191
|
+
webidl2jsWrapper.URL = URL;
|
|
1192
|
+
webidl2jsWrapper.URLSearchParams = URLSearchParams;
|
|
1193
|
+
return webidl2jsWrapper;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
require("@exodus/bytes/encoding.js"); // for legacy multi-byte encodings
|
|
1197
|
+
var _require$2 = require("@exodus/bytes/whatwg.js"),
|
|
1198
|
+
percentEncodeAfterEncoding = _require$2.percentEncodeAfterEncoding;
|
|
1199
|
+
var infra$2 = require("./infra");
|
|
1200
|
+
var _require2$1 = require("./encoding"),
|
|
1201
|
+
utf8DecodeWithoutBOM = _require2$1.utf8DecodeWithoutBOM;
|
|
1202
|
+
var _require3 = require("./url-miscellaneous"),
|
|
1203
|
+
containsForbiddenHostCodePoint$1 = _require3.containsForbiddenHostCodePoint,
|
|
1204
|
+
containsPercentEncodedByte$1 = _require3.containsPercentEncodedByte,
|
|
1205
|
+
defaultPort$1 = _require3.defaultPort,
|
|
1206
|
+
domainParser$1 = _require3.domainParser,
|
|
1207
|
+
endsInANumber$1 = _require3.endsInANumber,
|
|
1208
|
+
failure$1 = _require3.failure,
|
|
1209
|
+
isInvalidURLCodePoint$1 = _require3.isInvalidURLCodePoint,
|
|
1210
|
+
isNormalizedWindowsDriveLetterString$1 = _require3.isNormalizedWindowsDriveLetterString,
|
|
1211
|
+
isSpecialScheme$1 = _require3.isSpecialScheme,
|
|
1212
|
+
isWindowsDriveLetterCodePoints$1 = _require3.isWindowsDriveLetterCodePoints,
|
|
1213
|
+
isWindowsDriveLetterString$1 = _require3.isWindowsDriveLetterString,
|
|
1214
|
+
parseIPv4Number$1 = _require3.parseIPv4Number,
|
|
1215
|
+
p$2 = _require3.p;
|
|
1216
|
+
var _require4 = require("./percent-encoding"),
|
|
1217
|
+
percentDecodeString$1 = _require4.percentDecodeString,
|
|
1218
|
+
utf8PercentEncodeCodePoint$1 = _require4.utf8PercentEncodeCodePoint,
|
|
1219
|
+
utf8PercentEncodeString$1 = _require4.utf8PercentEncodeString,
|
|
1220
|
+
isC0ControlPercentEncode$1 = _require4.isC0ControlPercentEncode,
|
|
1221
|
+
isFragmentPercentEncode$1 = _require4.isFragmentPercentEncode,
|
|
1222
|
+
extraQueryPercentEncodeChars$1 = _require4.extraQueryPercentEncodeChars,
|
|
1223
|
+
extraSpecialQueryPercentEncodeChars$1 = _require4.extraSpecialQueryPercentEncodeChars,
|
|
1224
|
+
isPathPercentEncode$1 = _require4.isPathPercentEncode,
|
|
1225
|
+
isUserinfoPercentEncode$1 = _require4.isUserinfoPercentEncode;
|
|
1226
|
+
function countSymbols(str) {
|
|
1227
|
+
return _toConsumableArray(str).length;
|
|
1228
|
+
}
|
|
1229
|
+
function at(input, idx) {
|
|
1230
|
+
var c = input[idx];
|
|
1231
|
+
return isNaN(c) ? undefined : String.fromCodePoint(c);
|
|
1232
|
+
}
|
|
1233
|
+
function isSingleDot(buffer) {
|
|
1234
|
+
return buffer === "." || buffer.toLowerCase() === "%2e";
|
|
1235
|
+
}
|
|
1236
|
+
function isDoubleDot(buffer) {
|
|
1237
|
+
buffer = buffer.toLowerCase();
|
|
1238
|
+
return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e";
|
|
1239
|
+
}
|
|
1240
|
+
function isInvalidPercentEncoding(input, pointer) {
|
|
1241
|
+
return input[pointer] === p$2("%") && (!infra$2.isASCIIHex(input[pointer + 1]) || !infra$2.isASCIIHex(input[pointer + 2]));
|
|
1242
|
+
}
|
|
1243
|
+
function validateURLUnits(input) {
|
|
1244
|
+
var validationErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1245
|
+
if (validationErrors === null) {
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
var codePoints = Array.from(input, function (c) {
|
|
1249
|
+
return c.codePointAt(0);
|
|
1250
|
+
});
|
|
1251
|
+
if (codePoints.some(isInvalidURLCodePoint$1)) {
|
|
1252
|
+
validationErrors.push("invalid-URL-unit");
|
|
1253
|
+
}
|
|
1254
|
+
if (codePoints.some(function (_, i) {
|
|
1255
|
+
return isInvalidPercentEncoding(codePoints, i);
|
|
1256
|
+
})) {
|
|
1257
|
+
validationErrors.push("invalid-URL-unit");
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
function isSpecial(url) {
|
|
1261
|
+
return isSpecialScheme$1(url.scheme);
|
|
1262
|
+
}
|
|
1263
|
+
function isNotSpecial(url) {
|
|
1264
|
+
return !isSpecialScheme$1(url.scheme);
|
|
1265
|
+
}
|
|
1266
|
+
function parseIPv4(input) {
|
|
1267
|
+
var validationErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1268
|
+
var parts = input.split(".");
|
|
1269
|
+
if (parts[parts.length - 1] === "") {
|
|
1270
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-empty-part");
|
|
1271
|
+
if (parts.length > 1) {
|
|
1272
|
+
parts.pop();
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (parts.length > 4) {
|
|
1276
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-too-many-parts");
|
|
1277
|
+
return failure$1;
|
|
1278
|
+
}
|
|
1279
|
+
if (parts.length < 4) {
|
|
1280
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-too-few-parts");
|
|
1281
|
+
}
|
|
1282
|
+
var numbers = [];
|
|
1283
|
+
var _iterator = _createForOfIteratorHelper(parts),
|
|
1284
|
+
_step;
|
|
1285
|
+
try {
|
|
1286
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1287
|
+
var part = _step.value;
|
|
1288
|
+
var _n = parseIPv4Number$1(part, validationErrors);
|
|
1289
|
+
if (_n === failure$1) {
|
|
1290
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-non-numeric-part");
|
|
1291
|
+
return failure$1;
|
|
1292
|
+
}
|
|
1293
|
+
numbers.push(_n);
|
|
1294
|
+
}
|
|
1295
|
+
} catch (err) {
|
|
1296
|
+
_iterator.e(err);
|
|
1297
|
+
} finally {
|
|
1298
|
+
_iterator.f();
|
|
1299
|
+
}
|
|
1300
|
+
if (validationErrors !== null && numbers.some(function (n) {
|
|
1301
|
+
return n > 255;
|
|
1302
|
+
})) {
|
|
1303
|
+
validationErrors.push("IPv4-out-of-range-part");
|
|
1304
|
+
}
|
|
1305
|
+
for (var i = 0; i < numbers.length - 1; ++i) {
|
|
1306
|
+
if (numbers[i] > 255) {
|
|
1307
|
+
return failure$1;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) {
|
|
1311
|
+
return failure$1;
|
|
1312
|
+
}
|
|
1313
|
+
var ipv4 = numbers.pop();
|
|
1314
|
+
var counter = 0;
|
|
1315
|
+
for (var _i = 0, _numbers = numbers; _i < _numbers.length; _i++) {
|
|
1316
|
+
var n = _numbers[_i];
|
|
1317
|
+
ipv4 += n * Math.pow(256, 3 - counter);
|
|
1318
|
+
++counter;
|
|
1319
|
+
}
|
|
1320
|
+
return ipv4;
|
|
1321
|
+
}
|
|
1322
|
+
function serializeIPv4(address) {
|
|
1323
|
+
var output = "";
|
|
1324
|
+
var n = address;
|
|
1325
|
+
for (var i = 1; i <= 4; ++i) {
|
|
1326
|
+
output = String(n % 256) + output;
|
|
1327
|
+
if (i !== 4) {
|
|
1328
|
+
output = ".".concat(output);
|
|
1329
|
+
}
|
|
1330
|
+
n = Math.floor(n / 256);
|
|
1331
|
+
}
|
|
1332
|
+
return output;
|
|
1333
|
+
}
|
|
1334
|
+
function parseIPv6(input) {
|
|
1335
|
+
var validationErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1336
|
+
var address = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
1337
|
+
var pieceIndex = 0;
|
|
1338
|
+
var compress = null;
|
|
1339
|
+
var pointer = 0;
|
|
1340
|
+
input = Array.from(input, function (c) {
|
|
1341
|
+
return c.codePointAt(0);
|
|
1342
|
+
});
|
|
1343
|
+
if (input[pointer] === p$2(":")) {
|
|
1344
|
+
if (input[pointer + 1] !== p$2(":")) {
|
|
1345
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv6-invalid-compression");
|
|
1346
|
+
return failure$1;
|
|
1347
|
+
}
|
|
1348
|
+
pointer += 2;
|
|
1349
|
+
++pieceIndex;
|
|
1350
|
+
compress = pieceIndex;
|
|
1351
|
+
}
|
|
1352
|
+
while (pointer < input.length) {
|
|
1353
|
+
if (pieceIndex === 8) {
|
|
1354
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv6-too-many-pieces");
|
|
1355
|
+
return failure$1;
|
|
1356
|
+
}
|
|
1357
|
+
if (input[pointer] === p$2(":")) {
|
|
1358
|
+
if (compress !== null) {
|
|
1359
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv6-multiple-compression");
|
|
1360
|
+
return failure$1;
|
|
1361
|
+
}
|
|
1362
|
+
++pointer;
|
|
1363
|
+
++pieceIndex;
|
|
1364
|
+
compress = pieceIndex;
|
|
1365
|
+
continue;
|
|
1366
|
+
}
|
|
1367
|
+
var value = 0;
|
|
1368
|
+
var length = 0;
|
|
1369
|
+
while (length < 4 && infra$2.isASCIIHex(input[pointer])) {
|
|
1370
|
+
value = value * 0x10 + parseInt(at(input, pointer), 16);
|
|
1371
|
+
++pointer;
|
|
1372
|
+
++length;
|
|
1373
|
+
}
|
|
1374
|
+
if (input[pointer] === p$2(".")) {
|
|
1375
|
+
if (length === 0) {
|
|
1376
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-in-IPv6-invalid-code-point");
|
|
1377
|
+
return failure$1;
|
|
1378
|
+
}
|
|
1379
|
+
pointer -= length;
|
|
1380
|
+
if (pieceIndex > 6) {
|
|
1381
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-in-IPv6-too-many-pieces");
|
|
1382
|
+
return failure$1;
|
|
1383
|
+
}
|
|
1384
|
+
var numbersSeen = 0;
|
|
1385
|
+
while (input[pointer] !== undefined) {
|
|
1386
|
+
var ipv4Piece = null;
|
|
1387
|
+
if (numbersSeen > 0) {
|
|
1388
|
+
if (input[pointer] === p$2(".") && numbersSeen < 4) {
|
|
1389
|
+
++pointer;
|
|
1390
|
+
} else {
|
|
1391
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-in-IPv6-invalid-code-point");
|
|
1392
|
+
return failure$1;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
if (!infra$2.isASCIIDigit(input[pointer])) {
|
|
1396
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-in-IPv6-invalid-code-point");
|
|
1397
|
+
return failure$1;
|
|
1398
|
+
}
|
|
1399
|
+
while (infra$2.isASCIIDigit(input[pointer])) {
|
|
1400
|
+
var number = parseInt(at(input, pointer), 10);
|
|
1401
|
+
if (ipv4Piece === null) {
|
|
1402
|
+
ipv4Piece = number;
|
|
1403
|
+
} else if (ipv4Piece === 0) {
|
|
1404
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-in-IPv6-invalid-code-point");
|
|
1405
|
+
return failure$1;
|
|
1406
|
+
} else {
|
|
1407
|
+
ipv4Piece = ipv4Piece * 10 + number;
|
|
1408
|
+
}
|
|
1409
|
+
if (ipv4Piece > 255) {
|
|
1410
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-in-IPv6-out-of-range-part");
|
|
1411
|
+
return failure$1;
|
|
1412
|
+
}
|
|
1413
|
+
++pointer;
|
|
1414
|
+
}
|
|
1415
|
+
address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece;
|
|
1416
|
+
++numbersSeen;
|
|
1417
|
+
if (numbersSeen === 2 || numbersSeen === 4) {
|
|
1418
|
+
++pieceIndex;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
if (numbersSeen !== 4) {
|
|
1422
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-in-IPv6-too-few-parts");
|
|
1423
|
+
return failure$1;
|
|
1424
|
+
}
|
|
1425
|
+
break;
|
|
1426
|
+
} else if (input[pointer] === p$2(":")) {
|
|
1427
|
+
++pointer;
|
|
1428
|
+
if (input[pointer] === undefined) {
|
|
1429
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv6-invalid-code-point");
|
|
1430
|
+
return failure$1;
|
|
1431
|
+
}
|
|
1432
|
+
} else if (input[pointer] !== undefined) {
|
|
1433
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv6-invalid-code-point");
|
|
1434
|
+
return failure$1;
|
|
1435
|
+
}
|
|
1436
|
+
if (length > 1 && value < Math.pow(0x10, length - 1)) {
|
|
1437
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv6-piece-leading-zero");
|
|
1438
|
+
}
|
|
1439
|
+
address[pieceIndex] = value;
|
|
1440
|
+
++pieceIndex;
|
|
1441
|
+
}
|
|
1442
|
+
if (compress !== null) {
|
|
1443
|
+
var swaps = pieceIndex - compress;
|
|
1444
|
+
pieceIndex = 7;
|
|
1445
|
+
while (pieceIndex !== 0 && swaps > 0) {
|
|
1446
|
+
var temp = address[compress + swaps - 1];
|
|
1447
|
+
address[compress + swaps - 1] = address[pieceIndex];
|
|
1448
|
+
address[pieceIndex] = temp;
|
|
1449
|
+
--pieceIndex;
|
|
1450
|
+
--swaps;
|
|
1451
|
+
}
|
|
1452
|
+
} else if (compress === null && pieceIndex !== 8) {
|
|
1453
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv6-too-few-pieces");
|
|
1454
|
+
return failure$1;
|
|
1455
|
+
}
|
|
1456
|
+
return address;
|
|
1457
|
+
}
|
|
1458
|
+
function serializeIPv6(address) {
|
|
1459
|
+
var output = "";
|
|
1460
|
+
var compress = findTheIPv6AddressCompressedPieceIndex(address);
|
|
1461
|
+
var ignore0 = false;
|
|
1462
|
+
for (var pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) {
|
|
1463
|
+
if (ignore0 && address[pieceIndex] === 0) {
|
|
1464
|
+
continue;
|
|
1465
|
+
} else if (ignore0) {
|
|
1466
|
+
ignore0 = false;
|
|
1467
|
+
}
|
|
1468
|
+
if (compress === pieceIndex) {
|
|
1469
|
+
var separator = pieceIndex === 0 ? "::" : ":";
|
|
1470
|
+
output += separator;
|
|
1471
|
+
ignore0 = true;
|
|
1472
|
+
continue;
|
|
1473
|
+
}
|
|
1474
|
+
output += address[pieceIndex].toString(16);
|
|
1475
|
+
if (pieceIndex !== 7) {
|
|
1476
|
+
output += ":";
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
return output;
|
|
1480
|
+
}
|
|
1481
|
+
function parseHost(input) {
|
|
1482
|
+
var validationErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1483
|
+
var isOpaque = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1484
|
+
if (input[0] === "[") {
|
|
1485
|
+
if (input[input.length - 1] !== "]") {
|
|
1486
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv6-unclosed");
|
|
1487
|
+
return failure$1;
|
|
1488
|
+
}
|
|
1489
|
+
return parseIPv6(input.substring(1, input.length - 1), validationErrors);
|
|
1490
|
+
}
|
|
1491
|
+
if (isOpaque) {
|
|
1492
|
+
return parseOpaqueHost(input, validationErrors);
|
|
1493
|
+
}
|
|
1494
|
+
if (validationErrors && containsPercentEncodedByte$1(input)) {
|
|
1495
|
+
validationErrors.push("domain-percent-encoded");
|
|
1496
|
+
}
|
|
1497
|
+
var domain = utf8DecodeWithoutBOM(percentDecodeString$1(input));
|
|
1498
|
+
var asciiDomain = domainParser$1(domain, validationErrors);
|
|
1499
|
+
if (asciiDomain === failure$1) {
|
|
1500
|
+
return failure$1;
|
|
1501
|
+
}
|
|
1502
|
+
if (endsInANumber$1(asciiDomain)) {
|
|
1503
|
+
if (!infra$2.isASCIIString(domain)) {
|
|
1504
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-non-ASCII-input");
|
|
1505
|
+
}
|
|
1506
|
+
return parseIPv4(asciiDomain, validationErrors);
|
|
1507
|
+
}
|
|
1508
|
+
return asciiDomain;
|
|
1509
|
+
}
|
|
1510
|
+
function parseOpaqueHost(input, validationErrors) {
|
|
1511
|
+
if (containsForbiddenHostCodePoint$1(input)) {
|
|
1512
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("host-invalid-code-point");
|
|
1513
|
+
return failure$1;
|
|
1514
|
+
}
|
|
1515
|
+
validateURLUnits(input, validationErrors);
|
|
1516
|
+
return utf8PercentEncodeString$1(input, isC0ControlPercentEncode$1);
|
|
1517
|
+
}
|
|
1518
|
+
function findTheIPv6AddressCompressedPieceIndex(address) {
|
|
1519
|
+
var longestIndex = null;
|
|
1520
|
+
var longestSize = 1; // only find elements > 1
|
|
1521
|
+
var foundIndex = null;
|
|
1522
|
+
var foundSize = 0;
|
|
1523
|
+
for (var pieceIndex = 0; pieceIndex < address.length; ++pieceIndex) {
|
|
1524
|
+
if (address[pieceIndex] !== 0) {
|
|
1525
|
+
if (foundSize > longestSize) {
|
|
1526
|
+
longestIndex = foundIndex;
|
|
1527
|
+
longestSize = foundSize;
|
|
1528
|
+
}
|
|
1529
|
+
foundIndex = null;
|
|
1530
|
+
foundSize = 0;
|
|
1531
|
+
} else {
|
|
1532
|
+
if (foundIndex === null) {
|
|
1533
|
+
foundIndex = pieceIndex;
|
|
1534
|
+
}
|
|
1535
|
+
++foundSize;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
if (foundSize > longestSize) {
|
|
1539
|
+
return foundIndex;
|
|
1540
|
+
}
|
|
1541
|
+
return longestIndex;
|
|
1542
|
+
}
|
|
1543
|
+
function serializeHost(host) {
|
|
1544
|
+
if (typeof host === "number") {
|
|
1545
|
+
return serializeIPv4(host);
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
// IPv6 serializer
|
|
1549
|
+
if (host instanceof Array) {
|
|
1550
|
+
return "[".concat(serializeIPv6(host), "]");
|
|
1551
|
+
}
|
|
1552
|
+
return host;
|
|
1553
|
+
}
|
|
1554
|
+
function trimControlChars(string) {
|
|
1555
|
+
// Avoid using regexp because of this V8 bug: https://issues.chromium.org/issues/42204424
|
|
1556
|
+
|
|
1557
|
+
var start = 0;
|
|
1558
|
+
var end = string.length;
|
|
1559
|
+
for (; start < end; ++start) {
|
|
1560
|
+
if (string.charCodeAt(start) > 0x20) {
|
|
1561
|
+
break;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
for (; end > start; --end) {
|
|
1565
|
+
if (string.charCodeAt(end - 1) > 0x20) {
|
|
1566
|
+
break;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
return string.substring(start, end);
|
|
1570
|
+
}
|
|
1571
|
+
function trimTabAndNewline(url) {
|
|
1572
|
+
return url.replace(/\t|\n|\r/g, "");
|
|
1573
|
+
}
|
|
1574
|
+
function shortenPath(url) {
|
|
1575
|
+
var path = url.path;
|
|
1576
|
+
if (path.length === 0) {
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetterString$1(path[0])) {
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
path.pop();
|
|
1583
|
+
}
|
|
1584
|
+
function includesCredentials(url) {
|
|
1585
|
+
return url.username !== "" || url.password !== "";
|
|
1586
|
+
}
|
|
1587
|
+
function cannotHaveAUsernamePasswordPort(url) {
|
|
1588
|
+
return url.host === null || url.host === "" || url.scheme === "file";
|
|
1589
|
+
}
|
|
1590
|
+
function hasAnOpaquePath(url) {
|
|
1591
|
+
return typeof url.path === "string";
|
|
1592
|
+
}
|
|
1593
|
+
function URLStateMachine(input, base, encoding, url, stateOverride) {
|
|
1594
|
+
var validationErrors = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
|
|
1595
|
+
this.pointer = 0;
|
|
1596
|
+
this.input = input;
|
|
1597
|
+
this.base = base || null;
|
|
1598
|
+
this.encoding = encoding || "utf-8";
|
|
1599
|
+
this.stateOverride = stateOverride;
|
|
1600
|
+
this.url = url;
|
|
1601
|
+
this.failure = false;
|
|
1602
|
+
this.validationErrors = validationErrors;
|
|
1603
|
+
if (!this.url) {
|
|
1604
|
+
this.url = {
|
|
1605
|
+
scheme: "",
|
|
1606
|
+
username: "",
|
|
1607
|
+
password: "",
|
|
1608
|
+
host: null,
|
|
1609
|
+
port: null,
|
|
1610
|
+
path: [],
|
|
1611
|
+
query: null,
|
|
1612
|
+
fragment: null
|
|
1613
|
+
};
|
|
1614
|
+
var _res = trimControlChars(this.input);
|
|
1615
|
+
if (_res !== this.input) {
|
|
1616
|
+
var _this$validationError;
|
|
1617
|
+
(_this$validationError = this.validationErrors) === null || _this$validationError === void 0 || _this$validationError.push("invalid-URL-unit");
|
|
1618
|
+
}
|
|
1619
|
+
this.input = _res;
|
|
1620
|
+
}
|
|
1621
|
+
var res = trimTabAndNewline(this.input);
|
|
1622
|
+
if (res !== this.input) {
|
|
1623
|
+
var _this$validationError2;
|
|
1624
|
+
(_this$validationError2 = this.validationErrors) === null || _this$validationError2 === void 0 || _this$validationError2.push("invalid-URL-unit");
|
|
1625
|
+
}
|
|
1626
|
+
this.input = res;
|
|
1627
|
+
this.state = stateOverride || "scheme start";
|
|
1628
|
+
this.buffer = "";
|
|
1629
|
+
this.atSignSeen = false;
|
|
1630
|
+
this.insideBrackets = false;
|
|
1631
|
+
this.passwordTokenSeen = false;
|
|
1632
|
+
this.input = Array.from(this.input, function (c) {
|
|
1633
|
+
return c.codePointAt(0);
|
|
1634
|
+
});
|
|
1635
|
+
for (; this.pointer <= this.input.length; ++this.pointer) {
|
|
1636
|
+
var c = this.input[this.pointer];
|
|
1637
|
+
var cStr = isNaN(c) ? undefined : String.fromCodePoint(c);
|
|
1638
|
+
|
|
1639
|
+
// exec state machine
|
|
1640
|
+
var ret = this["parse ".concat(this.state)](c, cStr);
|
|
1641
|
+
if (!ret) {
|
|
1642
|
+
break; // terminate algorithm
|
|
1643
|
+
} else if (ret === failure$1) {
|
|
1644
|
+
this.failure = true;
|
|
1645
|
+
break;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
URLStateMachine.prototype.validateURLUnit = function (c) {
|
|
1650
|
+
if (this.validationErrors === null) {
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
if (isInvalidURLCodePoint$1(c)) {
|
|
1654
|
+
this.validationErrors.push("invalid-URL-unit");
|
|
1655
|
+
}
|
|
1656
|
+
if (isInvalidPercentEncoding(this.input, this.pointer)) {
|
|
1657
|
+
this.validationErrors.push("invalid-URL-unit");
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) {
|
|
1661
|
+
if (infra$2.isASCIIAlpha(c)) {
|
|
1662
|
+
this.buffer += cStr.toLowerCase();
|
|
1663
|
+
this.state = "scheme";
|
|
1664
|
+
} else if (!this.stateOverride) {
|
|
1665
|
+
this.state = "no scheme";
|
|
1666
|
+
--this.pointer;
|
|
1667
|
+
} else {
|
|
1668
|
+
return failure$1;
|
|
1669
|
+
}
|
|
1670
|
+
return true;
|
|
1671
|
+
};
|
|
1672
|
+
URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) {
|
|
1673
|
+
if (infra$2.isASCIIAlphanumeric(c) || c === p$2("+") || c === p$2("-") || c === p$2(".")) {
|
|
1674
|
+
this.buffer += cStr.toLowerCase();
|
|
1675
|
+
} else if (c === p$2(":")) {
|
|
1676
|
+
if (this.stateOverride) {
|
|
1677
|
+
if (isSpecial(this.url) && !isSpecialScheme$1(this.buffer)) {
|
|
1678
|
+
return false;
|
|
1679
|
+
}
|
|
1680
|
+
if (!isSpecial(this.url) && isSpecialScheme$1(this.buffer)) {
|
|
1681
|
+
return false;
|
|
1682
|
+
}
|
|
1683
|
+
if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") {
|
|
1684
|
+
return false;
|
|
1685
|
+
}
|
|
1686
|
+
if (this.url.scheme === "file" && this.url.host === "") {
|
|
1687
|
+
return false;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
this.url.scheme = this.buffer;
|
|
1691
|
+
if (this.stateOverride) {
|
|
1692
|
+
if (this.url.port === defaultPort$1(this.url.scheme)) {
|
|
1693
|
+
this.url.port = null;
|
|
1694
|
+
}
|
|
1695
|
+
return false;
|
|
1696
|
+
}
|
|
1697
|
+
this.buffer = "";
|
|
1698
|
+
if (this.url.scheme === "file") {
|
|
1699
|
+
if (this.input[this.pointer + 1] !== p$2("/") || this.input[this.pointer + 2] !== p$2("/")) {
|
|
1700
|
+
var _this$validationError3;
|
|
1701
|
+
(_this$validationError3 = this.validationErrors) === null || _this$validationError3 === void 0 || _this$validationError3.push("special-scheme-missing-following-solidus");
|
|
1702
|
+
}
|
|
1703
|
+
this.state = "file";
|
|
1704
|
+
} else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) {
|
|
1705
|
+
this.state = "special relative or authority";
|
|
1706
|
+
} else if (isSpecial(this.url)) {
|
|
1707
|
+
this.state = "special authority slashes";
|
|
1708
|
+
} else if (this.input[this.pointer + 1] === p$2("/")) {
|
|
1709
|
+
this.state = "path or authority";
|
|
1710
|
+
++this.pointer;
|
|
1711
|
+
} else {
|
|
1712
|
+
this.url.path = "";
|
|
1713
|
+
this.state = "opaque path";
|
|
1714
|
+
}
|
|
1715
|
+
} else if (!this.stateOverride) {
|
|
1716
|
+
this.buffer = "";
|
|
1717
|
+
this.state = "no scheme";
|
|
1718
|
+
this.pointer = -1;
|
|
1719
|
+
} else {
|
|
1720
|
+
return failure$1;
|
|
1721
|
+
}
|
|
1722
|
+
return true;
|
|
1723
|
+
};
|
|
1724
|
+
URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) {
|
|
1725
|
+
if (this.base === null || hasAnOpaquePath(this.base) && c !== p$2("#")) {
|
|
1726
|
+
var _this$validationError4;
|
|
1727
|
+
(_this$validationError4 = this.validationErrors) === null || _this$validationError4 === void 0 || _this$validationError4.push("missing-scheme-non-relative-URL");
|
|
1728
|
+
return failure$1;
|
|
1729
|
+
} else if (hasAnOpaquePath(this.base) && c === p$2("#")) {
|
|
1730
|
+
this.url.scheme = this.base.scheme;
|
|
1731
|
+
this.url.path = this.base.path;
|
|
1732
|
+
this.url.query = this.base.query;
|
|
1733
|
+
this.url.fragment = "";
|
|
1734
|
+
this.state = "fragment";
|
|
1735
|
+
} else if (this.base.scheme === "file") {
|
|
1736
|
+
this.state = "file";
|
|
1737
|
+
--this.pointer;
|
|
1738
|
+
} else {
|
|
1739
|
+
this.state = "relative";
|
|
1740
|
+
--this.pointer;
|
|
1741
|
+
}
|
|
1742
|
+
return true;
|
|
1743
|
+
};
|
|
1744
|
+
URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) {
|
|
1745
|
+
if (c === p$2("/") && this.input[this.pointer + 1] === p$2("/")) {
|
|
1746
|
+
this.state = "special authority ignore slashes";
|
|
1747
|
+
++this.pointer;
|
|
1748
|
+
} else {
|
|
1749
|
+
var _this$validationError5;
|
|
1750
|
+
(_this$validationError5 = this.validationErrors) === null || _this$validationError5 === void 0 || _this$validationError5.push("special-scheme-missing-following-solidus");
|
|
1751
|
+
this.state = "relative";
|
|
1752
|
+
--this.pointer;
|
|
1753
|
+
}
|
|
1754
|
+
return true;
|
|
1755
|
+
};
|
|
1756
|
+
URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) {
|
|
1757
|
+
if (c === p$2("/")) {
|
|
1758
|
+
this.state = "authority";
|
|
1759
|
+
} else {
|
|
1760
|
+
this.state = "path";
|
|
1761
|
+
--this.pointer;
|
|
1762
|
+
}
|
|
1763
|
+
return true;
|
|
1764
|
+
};
|
|
1765
|
+
URLStateMachine.prototype["parse relative"] = function parseRelative(c) {
|
|
1766
|
+
this.url.scheme = this.base.scheme;
|
|
1767
|
+
if (c === p$2("/")) {
|
|
1768
|
+
this.state = "relative slash";
|
|
1769
|
+
} else if (isSpecial(this.url) && c === p$2("\\")) {
|
|
1770
|
+
var _this$validationError6;
|
|
1771
|
+
(_this$validationError6 = this.validationErrors) === null || _this$validationError6 === void 0 || _this$validationError6.push("invalid-reverse-solidus");
|
|
1772
|
+
this.state = "relative slash";
|
|
1773
|
+
} else {
|
|
1774
|
+
this.url.username = this.base.username;
|
|
1775
|
+
this.url.password = this.base.password;
|
|
1776
|
+
this.url.host = this.base.host;
|
|
1777
|
+
this.url.port = this.base.port;
|
|
1778
|
+
this.url.path = this.base.path.slice();
|
|
1779
|
+
this.url.query = this.base.query;
|
|
1780
|
+
if (c === p$2("?")) {
|
|
1781
|
+
this.url.query = "";
|
|
1782
|
+
this.state = "query";
|
|
1783
|
+
} else if (c === p$2("#")) {
|
|
1784
|
+
this.url.fragment = "";
|
|
1785
|
+
this.state = "fragment";
|
|
1786
|
+
} else if (!isNaN(c)) {
|
|
1787
|
+
this.url.query = null;
|
|
1788
|
+
this.url.path.pop();
|
|
1789
|
+
this.state = "path";
|
|
1790
|
+
--this.pointer;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
return true;
|
|
1794
|
+
};
|
|
1795
|
+
URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) {
|
|
1796
|
+
if (isSpecial(this.url) && (c === p$2("/") || c === p$2("\\"))) {
|
|
1797
|
+
if (c === p$2("\\")) {
|
|
1798
|
+
var _this$validationError7;
|
|
1799
|
+
(_this$validationError7 = this.validationErrors) === null || _this$validationError7 === void 0 || _this$validationError7.push("invalid-reverse-solidus");
|
|
1800
|
+
}
|
|
1801
|
+
this.state = "special authority ignore slashes";
|
|
1802
|
+
} else if (c === p$2("/")) {
|
|
1803
|
+
this.state = "authority";
|
|
1804
|
+
} else {
|
|
1805
|
+
this.url.username = this.base.username;
|
|
1806
|
+
this.url.password = this.base.password;
|
|
1807
|
+
this.url.host = this.base.host;
|
|
1808
|
+
this.url.port = this.base.port;
|
|
1809
|
+
this.state = "path";
|
|
1810
|
+
--this.pointer;
|
|
1811
|
+
}
|
|
1812
|
+
return true;
|
|
1813
|
+
};
|
|
1814
|
+
URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) {
|
|
1815
|
+
if (c === p$2("/") && this.input[this.pointer + 1] === p$2("/")) {
|
|
1816
|
+
this.state = "special authority ignore slashes";
|
|
1817
|
+
++this.pointer;
|
|
1818
|
+
} else {
|
|
1819
|
+
var _this$validationError8;
|
|
1820
|
+
(_this$validationError8 = this.validationErrors) === null || _this$validationError8 === void 0 || _this$validationError8.push("special-scheme-missing-following-solidus");
|
|
1821
|
+
this.state = "special authority ignore slashes";
|
|
1822
|
+
--this.pointer;
|
|
1823
|
+
}
|
|
1824
|
+
return true;
|
|
1825
|
+
};
|
|
1826
|
+
URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) {
|
|
1827
|
+
if (c !== p$2("/") && c !== p$2("\\")) {
|
|
1828
|
+
this.state = "authority";
|
|
1829
|
+
--this.pointer;
|
|
1830
|
+
} else {
|
|
1831
|
+
var _this$validationError9;
|
|
1832
|
+
(_this$validationError9 = this.validationErrors) === null || _this$validationError9 === void 0 || _this$validationError9.push("special-scheme-missing-following-solidus");
|
|
1833
|
+
}
|
|
1834
|
+
return true;
|
|
1835
|
+
};
|
|
1836
|
+
URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) {
|
|
1837
|
+
if (c === p$2("@")) {
|
|
1838
|
+
var _this$validationError0;
|
|
1839
|
+
(_this$validationError0 = this.validationErrors) === null || _this$validationError0 === void 0 || _this$validationError0.push("invalid-credentials");
|
|
1840
|
+
if (this.atSignSeen) {
|
|
1841
|
+
this.buffer = "%40".concat(this.buffer);
|
|
1842
|
+
}
|
|
1843
|
+
this.atSignSeen = true;
|
|
1844
|
+
|
|
1845
|
+
// careful, this iterates over the buffer's code points, independently of this.pointer
|
|
1846
|
+
var _iterator2 = _createForOfIteratorHelper(this.buffer),
|
|
1847
|
+
_step2;
|
|
1848
|
+
try {
|
|
1849
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1850
|
+
var codePointStr = _step2.value;
|
|
1851
|
+
var codePoint = codePointStr.codePointAt(0);
|
|
1852
|
+
if (codePoint === p$2(":") && !this.passwordTokenSeen) {
|
|
1853
|
+
this.passwordTokenSeen = true;
|
|
1854
|
+
continue;
|
|
1855
|
+
}
|
|
1856
|
+
var encodedCodePoints = utf8PercentEncodeCodePoint$1(codePoint, isUserinfoPercentEncode$1);
|
|
1857
|
+
if (this.passwordTokenSeen) {
|
|
1858
|
+
this.url.password += encodedCodePoints;
|
|
1859
|
+
} else {
|
|
1860
|
+
this.url.username += encodedCodePoints;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
} catch (err) {
|
|
1864
|
+
_iterator2.e(err);
|
|
1865
|
+
} finally {
|
|
1866
|
+
_iterator2.f();
|
|
1867
|
+
}
|
|
1868
|
+
this.buffer = "";
|
|
1869
|
+
} else if (isNaN(c) || c === p$2("/") || c === p$2("?") || c === p$2("#") || isSpecial(this.url) && c === p$2("\\")) {
|
|
1870
|
+
if (this.atSignSeen && this.buffer === "") {
|
|
1871
|
+
var _this$validationError1;
|
|
1872
|
+
(_this$validationError1 = this.validationErrors) === null || _this$validationError1 === void 0 || _this$validationError1.push("host-missing");
|
|
1873
|
+
return failure$1;
|
|
1874
|
+
}
|
|
1875
|
+
this.pointer -= countSymbols(this.buffer) + 1;
|
|
1876
|
+
this.buffer = "";
|
|
1877
|
+
this.state = "host";
|
|
1878
|
+
} else {
|
|
1879
|
+
this.buffer += cStr;
|
|
1880
|
+
}
|
|
1881
|
+
return true;
|
|
1882
|
+
};
|
|
1883
|
+
URLStateMachine.prototype["parse hostname"] = URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) {
|
|
1884
|
+
if (this.stateOverride && this.url.scheme === "file") {
|
|
1885
|
+
--this.pointer;
|
|
1886
|
+
this.state = "file host";
|
|
1887
|
+
} else if (c === p$2(":") && !this.insideBrackets) {
|
|
1888
|
+
if (this.buffer === "") {
|
|
1889
|
+
var _this$validationError10;
|
|
1890
|
+
(_this$validationError10 = this.validationErrors) === null || _this$validationError10 === void 0 || _this$validationError10.push("host-missing");
|
|
1891
|
+
return failure$1;
|
|
1892
|
+
}
|
|
1893
|
+
if (this.stateOverride === "hostname") {
|
|
1894
|
+
return failure$1;
|
|
1895
|
+
}
|
|
1896
|
+
var host = parseHost(this.buffer, this.validationErrors, isNotSpecial(this.url));
|
|
1897
|
+
if (host === failure$1) {
|
|
1898
|
+
return failure$1;
|
|
1899
|
+
}
|
|
1900
|
+
this.url.host = host;
|
|
1901
|
+
this.buffer = "";
|
|
1902
|
+
this.state = "port";
|
|
1903
|
+
} else if (isNaN(c) || c === p$2("/") || c === p$2("?") || c === p$2("#") || isSpecial(this.url) && c === p$2("\\")) {
|
|
1904
|
+
--this.pointer;
|
|
1905
|
+
if (isSpecial(this.url) && this.buffer === "") {
|
|
1906
|
+
var _this$validationError11;
|
|
1907
|
+
(_this$validationError11 = this.validationErrors) === null || _this$validationError11 === void 0 || _this$validationError11.push("host-missing");
|
|
1908
|
+
return failure$1;
|
|
1909
|
+
} else if (this.stateOverride && this.buffer === "" && (includesCredentials(this.url) || this.url.port !== null)) {
|
|
1910
|
+
return failure$1;
|
|
1911
|
+
}
|
|
1912
|
+
var _host = parseHost(this.buffer, this.validationErrors, isNotSpecial(this.url));
|
|
1913
|
+
if (_host === failure$1) {
|
|
1914
|
+
return failure$1;
|
|
1915
|
+
}
|
|
1916
|
+
this.url.host = _host;
|
|
1917
|
+
this.buffer = "";
|
|
1918
|
+
this.state = "path start";
|
|
1919
|
+
if (this.stateOverride) {
|
|
1920
|
+
return false;
|
|
1921
|
+
}
|
|
1922
|
+
} else {
|
|
1923
|
+
if (c === p$2("[")) {
|
|
1924
|
+
this.insideBrackets = true;
|
|
1925
|
+
} else if (c === p$2("]")) {
|
|
1926
|
+
this.insideBrackets = false;
|
|
1927
|
+
}
|
|
1928
|
+
this.buffer += cStr;
|
|
1929
|
+
}
|
|
1930
|
+
return true;
|
|
1931
|
+
};
|
|
1932
|
+
URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) {
|
|
1933
|
+
if (infra$2.isASCIIDigit(c)) {
|
|
1934
|
+
this.buffer += cStr;
|
|
1935
|
+
} else if (isNaN(c) || c === p$2("/") || c === p$2("?") || c === p$2("#") || isSpecial(this.url) && c === p$2("\\") || this.stateOverride) {
|
|
1936
|
+
if (this.buffer !== "") {
|
|
1937
|
+
var port = parseInt(this.buffer, 10);
|
|
1938
|
+
if (port > Math.pow(2, 16) - 1) {
|
|
1939
|
+
var _this$validationError12;
|
|
1940
|
+
(_this$validationError12 = this.validationErrors) === null || _this$validationError12 === void 0 || _this$validationError12.push("port-out-of-range");
|
|
1941
|
+
return failure$1;
|
|
1942
|
+
}
|
|
1943
|
+
this.url.port = port === defaultPort$1(this.url.scheme) ? null : port;
|
|
1944
|
+
this.buffer = "";
|
|
1945
|
+
if (this.stateOverride) {
|
|
1946
|
+
return false;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
if (this.stateOverride) {
|
|
1950
|
+
return failure$1;
|
|
1951
|
+
}
|
|
1952
|
+
this.state = "path start";
|
|
1953
|
+
--this.pointer;
|
|
1954
|
+
} else {
|
|
1955
|
+
var _this$validationError13;
|
|
1956
|
+
(_this$validationError13 = this.validationErrors) === null || _this$validationError13 === void 0 || _this$validationError13.push("port-invalid");
|
|
1957
|
+
return failure$1;
|
|
1958
|
+
}
|
|
1959
|
+
return true;
|
|
1960
|
+
};
|
|
1961
|
+
var fileOtherwiseCodePoints = new Set([p$2("/"), p$2("\\"), p$2("?"), p$2("#")]);
|
|
1962
|
+
function startsWithWindowsDriveLetter(input, pointer) {
|
|
1963
|
+
var length = input.length - pointer;
|
|
1964
|
+
return length >= 2 && isWindowsDriveLetterCodePoints$1(input[pointer], input[pointer + 1]) && (length === 2 || fileOtherwiseCodePoints.has(input[pointer + 2]));
|
|
1965
|
+
}
|
|
1966
|
+
URLStateMachine.prototype["parse file"] = function parseFile(c) {
|
|
1967
|
+
this.url.scheme = "file";
|
|
1968
|
+
this.url.host = "";
|
|
1969
|
+
if (c === p$2("/") || c === p$2("\\")) {
|
|
1970
|
+
if (c === p$2("\\")) {
|
|
1971
|
+
var _this$validationError14;
|
|
1972
|
+
(_this$validationError14 = this.validationErrors) === null || _this$validationError14 === void 0 || _this$validationError14.push("invalid-reverse-solidus");
|
|
1973
|
+
}
|
|
1974
|
+
this.state = "file slash";
|
|
1975
|
+
} else if (this.base !== null && this.base.scheme === "file") {
|
|
1976
|
+
this.url.host = this.base.host;
|
|
1977
|
+
this.url.path = this.base.path.slice();
|
|
1978
|
+
this.url.query = this.base.query;
|
|
1979
|
+
if (c === p$2("?")) {
|
|
1980
|
+
this.url.query = "";
|
|
1981
|
+
this.state = "query";
|
|
1982
|
+
} else if (c === p$2("#")) {
|
|
1983
|
+
this.url.fragment = "";
|
|
1984
|
+
this.state = "fragment";
|
|
1985
|
+
} else if (!isNaN(c)) {
|
|
1986
|
+
this.url.query = null;
|
|
1987
|
+
if (!startsWithWindowsDriveLetter(this.input, this.pointer)) {
|
|
1988
|
+
shortenPath(this.url);
|
|
1989
|
+
} else {
|
|
1990
|
+
var _this$validationError15;
|
|
1991
|
+
(_this$validationError15 = this.validationErrors) === null || _this$validationError15 === void 0 || _this$validationError15.push("file-invalid-Windows-drive-letter");
|
|
1992
|
+
this.url.path = [];
|
|
1993
|
+
}
|
|
1994
|
+
this.state = "path";
|
|
1995
|
+
--this.pointer;
|
|
1996
|
+
}
|
|
1997
|
+
} else {
|
|
1998
|
+
this.state = "path";
|
|
1999
|
+
--this.pointer;
|
|
2000
|
+
}
|
|
2001
|
+
return true;
|
|
2002
|
+
};
|
|
2003
|
+
URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
|
|
2004
|
+
if (c === p$2("/") || c === p$2("\\")) {
|
|
2005
|
+
if (c === p$2("\\")) {
|
|
2006
|
+
var _this$validationError16;
|
|
2007
|
+
(_this$validationError16 = this.validationErrors) === null || _this$validationError16 === void 0 || _this$validationError16.push("invalid-reverse-solidus");
|
|
2008
|
+
}
|
|
2009
|
+
this.state = "file host";
|
|
2010
|
+
} else {
|
|
2011
|
+
if (this.base !== null && this.base.scheme === "file") {
|
|
2012
|
+
if (!startsWithWindowsDriveLetter(this.input, this.pointer) && isNormalizedWindowsDriveLetterString$1(this.base.path[0])) {
|
|
2013
|
+
this.url.path.push(this.base.path[0]);
|
|
2014
|
+
}
|
|
2015
|
+
this.url.host = this.base.host;
|
|
2016
|
+
}
|
|
2017
|
+
this.state = "path";
|
|
2018
|
+
--this.pointer;
|
|
2019
|
+
}
|
|
2020
|
+
return true;
|
|
2021
|
+
};
|
|
2022
|
+
URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) {
|
|
2023
|
+
if (isNaN(c) || c === p$2("/") || c === p$2("\\") || c === p$2("?") || c === p$2("#")) {
|
|
2024
|
+
--this.pointer;
|
|
2025
|
+
if (!this.stateOverride && isWindowsDriveLetterString$1(this.buffer)) {
|
|
2026
|
+
var _this$validationError17;
|
|
2027
|
+
(_this$validationError17 = this.validationErrors) === null || _this$validationError17 === void 0 || _this$validationError17.push("file-invalid-Windows-drive-letter-host");
|
|
2028
|
+
this.state = "path";
|
|
2029
|
+
} else if (this.buffer === "") {
|
|
2030
|
+
this.url.host = "";
|
|
2031
|
+
if (this.stateOverride) {
|
|
2032
|
+
return false;
|
|
2033
|
+
}
|
|
2034
|
+
this.state = "path start";
|
|
2035
|
+
} else {
|
|
2036
|
+
var host = parseHost(this.buffer, this.validationErrors, isNotSpecial(this.url));
|
|
2037
|
+
if (host === failure$1) {
|
|
2038
|
+
return failure$1;
|
|
2039
|
+
}
|
|
2040
|
+
if (host === "localhost") {
|
|
2041
|
+
host = "";
|
|
2042
|
+
}
|
|
2043
|
+
this.url.host = host;
|
|
2044
|
+
if (this.stateOverride) {
|
|
2045
|
+
return false;
|
|
2046
|
+
}
|
|
2047
|
+
this.buffer = "";
|
|
2048
|
+
this.state = "path start";
|
|
2049
|
+
}
|
|
2050
|
+
} else {
|
|
2051
|
+
this.buffer += cStr;
|
|
2052
|
+
}
|
|
2053
|
+
return true;
|
|
2054
|
+
};
|
|
2055
|
+
URLStateMachine.prototype["parse path start"] = function parsePathStart(c) {
|
|
2056
|
+
if (isSpecial(this.url)) {
|
|
2057
|
+
if (c === p$2("\\")) {
|
|
2058
|
+
var _this$validationError18;
|
|
2059
|
+
(_this$validationError18 = this.validationErrors) === null || _this$validationError18 === void 0 || _this$validationError18.push("invalid-reverse-solidus");
|
|
2060
|
+
}
|
|
2061
|
+
this.state = "path";
|
|
2062
|
+
if (c !== p$2("/") && c !== p$2("\\")) {
|
|
2063
|
+
--this.pointer;
|
|
2064
|
+
}
|
|
2065
|
+
} else if (!this.stateOverride && c === p$2("?")) {
|
|
2066
|
+
this.url.query = "";
|
|
2067
|
+
this.state = "query";
|
|
2068
|
+
} else if (!this.stateOverride && c === p$2("#")) {
|
|
2069
|
+
this.url.fragment = "";
|
|
2070
|
+
this.state = "fragment";
|
|
2071
|
+
} else if (c !== undefined) {
|
|
2072
|
+
this.state = "path";
|
|
2073
|
+
if (c !== p$2("/")) {
|
|
2074
|
+
--this.pointer;
|
|
2075
|
+
}
|
|
2076
|
+
} else if (this.stateOverride && this.url.host === null) {
|
|
2077
|
+
this.url.path.push("");
|
|
2078
|
+
}
|
|
2079
|
+
return true;
|
|
2080
|
+
};
|
|
2081
|
+
URLStateMachine.prototype["parse path"] = function parsePath(c) {
|
|
2082
|
+
if (isNaN(c) || c === p$2("/") || isSpecial(this.url) && c === p$2("\\") || !this.stateOverride && (c === p$2("?") || c === p$2("#"))) {
|
|
2083
|
+
if (isSpecial(this.url) && c === p$2("\\")) {
|
|
2084
|
+
var _this$validationError19;
|
|
2085
|
+
(_this$validationError19 = this.validationErrors) === null || _this$validationError19 === void 0 || _this$validationError19.push("invalid-reverse-solidus");
|
|
2086
|
+
}
|
|
2087
|
+
if (isDoubleDot(this.buffer)) {
|
|
2088
|
+
shortenPath(this.url);
|
|
2089
|
+
if (c !== p$2("/") && !(isSpecial(this.url) && c === p$2("\\"))) {
|
|
2090
|
+
this.url.path.push("");
|
|
2091
|
+
}
|
|
2092
|
+
} else if (isSingleDot(this.buffer) && c !== p$2("/") && !(isSpecial(this.url) && c === p$2("\\"))) {
|
|
2093
|
+
this.url.path.push("");
|
|
2094
|
+
} else if (!isSingleDot(this.buffer)) {
|
|
2095
|
+
if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString$1(this.buffer)) {
|
|
2096
|
+
this.buffer = "".concat(this.buffer[0], ":");
|
|
2097
|
+
}
|
|
2098
|
+
this.url.path.push(this.buffer);
|
|
2099
|
+
}
|
|
2100
|
+
this.buffer = "";
|
|
2101
|
+
if (c === p$2("?")) {
|
|
2102
|
+
this.url.query = "";
|
|
2103
|
+
this.state = "query";
|
|
2104
|
+
}
|
|
2105
|
+
if (c === p$2("#")) {
|
|
2106
|
+
this.url.fragment = "";
|
|
2107
|
+
this.state = "fragment";
|
|
2108
|
+
}
|
|
2109
|
+
} else {
|
|
2110
|
+
this.validateURLUnit(c);
|
|
2111
|
+
this.buffer += utf8PercentEncodeCodePoint$1(c, isPathPercentEncode$1);
|
|
2112
|
+
}
|
|
2113
|
+
return true;
|
|
2114
|
+
};
|
|
2115
|
+
URLStateMachine.prototype["parse opaque path"] = function parseOpaquePath(c) {
|
|
2116
|
+
if (c === p$2("?")) {
|
|
2117
|
+
this.url.query = "";
|
|
2118
|
+
this.state = "query";
|
|
2119
|
+
} else if (c === p$2("#")) {
|
|
2120
|
+
this.url.fragment = "";
|
|
2121
|
+
this.state = "fragment";
|
|
2122
|
+
} else if (c === p$2(" ")) {
|
|
2123
|
+
var _this$validationError20;
|
|
2124
|
+
(_this$validationError20 = this.validationErrors) === null || _this$validationError20 === void 0 || _this$validationError20.push("invalid-URL-unit");
|
|
2125
|
+
var remaining = this.input[this.pointer + 1];
|
|
2126
|
+
if (remaining === p$2("?") || remaining === p$2("#")) {
|
|
2127
|
+
this.url.path += "%20";
|
|
2128
|
+
} else {
|
|
2129
|
+
this.url.path += " ";
|
|
2130
|
+
}
|
|
2131
|
+
} else if (!isNaN(c)) {
|
|
2132
|
+
this.validateURLUnit(c);
|
|
2133
|
+
this.url.path += utf8PercentEncodeCodePoint$1(c, isC0ControlPercentEncode$1);
|
|
2134
|
+
}
|
|
2135
|
+
return true;
|
|
2136
|
+
};
|
|
2137
|
+
URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) {
|
|
2138
|
+
if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") {
|
|
2139
|
+
this.encoding = "utf-8";
|
|
2140
|
+
}
|
|
2141
|
+
if (!this.stateOverride && c === p$2("#") || isNaN(c)) {
|
|
2142
|
+
var percentEncodeSet = isSpecial(this.url) ? extraSpecialQueryPercentEncodeChars$1 : extraQueryPercentEncodeChars$1;
|
|
2143
|
+
this.url.query += percentEncodeAfterEncoding(this.encoding, this.buffer, percentEncodeSet);
|
|
2144
|
+
this.buffer = "";
|
|
2145
|
+
if (c === p$2("#")) {
|
|
2146
|
+
this.url.fragment = "";
|
|
2147
|
+
this.state = "fragment";
|
|
2148
|
+
}
|
|
2149
|
+
} else if (!isNaN(c)) {
|
|
2150
|
+
this.validateURLUnit(c);
|
|
2151
|
+
this.buffer += cStr;
|
|
2152
|
+
}
|
|
2153
|
+
return true;
|
|
2154
|
+
};
|
|
2155
|
+
URLStateMachine.prototype["parse fragment"] = function parseFragment(c) {
|
|
2156
|
+
if (!isNaN(c)) {
|
|
2157
|
+
this.validateURLUnit(c);
|
|
2158
|
+
this.url.fragment += utf8PercentEncodeCodePoint$1(c, isFragmentPercentEncode$1);
|
|
2159
|
+
}
|
|
2160
|
+
return true;
|
|
2161
|
+
};
|
|
2162
|
+
function serializeURL(url, excludeFragment) {
|
|
2163
|
+
var output = "".concat(url.scheme, ":");
|
|
2164
|
+
if (url.host !== null) {
|
|
2165
|
+
output += "//";
|
|
2166
|
+
if (url.username !== "" || url.password !== "") {
|
|
2167
|
+
output += url.username;
|
|
2168
|
+
if (url.password !== "") {
|
|
2169
|
+
output += ":".concat(url.password);
|
|
2170
|
+
}
|
|
2171
|
+
output += "@";
|
|
2172
|
+
}
|
|
2173
|
+
output += serializeHost(url.host);
|
|
2174
|
+
if (url.port !== null) {
|
|
2175
|
+
output += ":".concat(url.port);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
if (url.host === null && !hasAnOpaquePath(url) && url.path.length > 1 && url.path[0] === "") {
|
|
2179
|
+
output += "/.";
|
|
2180
|
+
}
|
|
2181
|
+
output += serializePath(url);
|
|
2182
|
+
if (url.query !== null) {
|
|
2183
|
+
output += "?".concat(url.query);
|
|
2184
|
+
}
|
|
2185
|
+
if (!excludeFragment && url.fragment !== null) {
|
|
2186
|
+
output += "#".concat(url.fragment);
|
|
2187
|
+
}
|
|
2188
|
+
return output;
|
|
2189
|
+
}
|
|
2190
|
+
function serializeOrigin(tuple) {
|
|
2191
|
+
var result = "".concat(tuple.scheme, "://");
|
|
2192
|
+
result += serializeHost(tuple.host);
|
|
2193
|
+
if (tuple.port !== null) {
|
|
2194
|
+
result += ":".concat(tuple.port);
|
|
2195
|
+
}
|
|
2196
|
+
return result;
|
|
2197
|
+
}
|
|
2198
|
+
function serializePath(url) {
|
|
2199
|
+
if (hasAnOpaquePath(url)) {
|
|
2200
|
+
return url.path;
|
|
2201
|
+
}
|
|
2202
|
+
var output = "";
|
|
2203
|
+
var _iterator3 = _createForOfIteratorHelper(url.path),
|
|
2204
|
+
_step3;
|
|
2205
|
+
try {
|
|
2206
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2207
|
+
var segment = _step3.value;
|
|
2208
|
+
output += "/".concat(segment);
|
|
2209
|
+
}
|
|
2210
|
+
} catch (err) {
|
|
2211
|
+
_iterator3.e(err);
|
|
2212
|
+
} finally {
|
|
2213
|
+
_iterator3.f();
|
|
2214
|
+
}
|
|
2215
|
+
return output;
|
|
2216
|
+
}
|
|
2217
|
+
module.exports.serializeURL = serializeURL;
|
|
2218
|
+
module.exports.serializePath = serializePath;
|
|
2219
|
+
module.exports.serializeURLOrigin = function (url) {
|
|
2220
|
+
// https://url.spec.whatwg.org/#concept-url-origin
|
|
2221
|
+
switch (url.scheme) {
|
|
2222
|
+
case "blob":
|
|
2223
|
+
{
|
|
2224
|
+
var pathURL = module.exports.parseURL(serializePath(url));
|
|
2225
|
+
if (pathURL === null) {
|
|
2226
|
+
return "null";
|
|
2227
|
+
}
|
|
2228
|
+
if (pathURL.scheme !== "http" && pathURL.scheme !== "https") {
|
|
2229
|
+
return "null";
|
|
2230
|
+
}
|
|
2231
|
+
return module.exports.serializeURLOrigin(pathURL);
|
|
2232
|
+
}
|
|
2233
|
+
case "ftp":
|
|
2234
|
+
case "http":
|
|
2235
|
+
case "https":
|
|
2236
|
+
case "ws":
|
|
2237
|
+
case "wss":
|
|
2238
|
+
return serializeOrigin({
|
|
2239
|
+
scheme: url.scheme,
|
|
2240
|
+
host: url.host,
|
|
2241
|
+
port: url.port
|
|
2242
|
+
});
|
|
2243
|
+
case "file":
|
|
2244
|
+
// The spec says:
|
|
2245
|
+
// > Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin.
|
|
2246
|
+
// Browsers tested so far:
|
|
2247
|
+
// - Chrome says "file://", but treats file: URLs as cross-origin for most (all?) purposes; see e.g.
|
|
2248
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=37586
|
|
2249
|
+
// - Firefox says "null", but treats file: URLs as same-origin sometimes based on directory stuff; see
|
|
2250
|
+
// https://developer.mozilla.org/en-US/docs/Archive/Misc_top_level/Same-origin_policy_for_file:_URIs
|
|
2251
|
+
return "null";
|
|
2252
|
+
default:
|
|
2253
|
+
// serializing an opaque origin returns "null"
|
|
2254
|
+
return "null";
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2257
|
+
function basicURLParse(input) {
|
|
2258
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2259
|
+
var validationErrors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2260
|
+
var usm = new URLStateMachine(input, options.baseURL, options.encoding, options.url, options.stateOverride, validationErrors);
|
|
2261
|
+
if (usm.failure) {
|
|
2262
|
+
return null;
|
|
2263
|
+
}
|
|
2264
|
+
return usm.url;
|
|
2265
|
+
}
|
|
2266
|
+
module.exports.basicURLParse = function (input) {
|
|
2267
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2268
|
+
return basicURLParse(input, options);
|
|
2269
|
+
};
|
|
2270
|
+
module.exports.setTheUsername = function (url, username) {
|
|
2271
|
+
url.username = utf8PercentEncodeString$1(username, isUserinfoPercentEncode$1);
|
|
2272
|
+
};
|
|
2273
|
+
module.exports.setThePassword = function (url, password) {
|
|
2274
|
+
url.password = utf8PercentEncodeString$1(password, isUserinfoPercentEncode$1);
|
|
2275
|
+
};
|
|
2276
|
+
module.exports.serializeHost = serializeHost;
|
|
2277
|
+
module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort;
|
|
2278
|
+
module.exports.hasAnOpaquePath = hasAnOpaquePath;
|
|
2279
|
+
module.exports.serializeInteger = function (integer) {
|
|
2280
|
+
return String(integer);
|
|
2281
|
+
};
|
|
2282
|
+
module.exports.parseURL = function (input) {
|
|
2283
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2284
|
+
// We don't handle blobs, so this just delegates:
|
|
2285
|
+
return module.exports.basicURLParse(input, {
|
|
2286
|
+
baseURL: options.baseURL,
|
|
2287
|
+
encoding: options.encoding
|
|
2288
|
+
});
|
|
2289
|
+
};
|
|
2290
|
+
module.exports.parseURLWithValidationErrors = function (input) {
|
|
2291
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2292
|
+
var validationErrors = [];
|
|
2293
|
+
|
|
2294
|
+
// We don't handle blobs, so this just delegates:
|
|
2295
|
+
var url = basicURLParse(input, {
|
|
2296
|
+
baseURL: options.baseURL,
|
|
2297
|
+
encoding: options.encoding
|
|
2298
|
+
}, validationErrors);
|
|
2299
|
+
return {
|
|
2300
|
+
url: url,
|
|
2301
|
+
validationErrors: validationErrors
|
|
2302
|
+
};
|
|
2303
|
+
};
|
|
2304
|
+
|
|
2305
|
+
var urlStateMachine = /*#__PURE__*/Object.freeze({
|
|
2306
|
+
__proto__: null
|
|
2307
|
+
});
|
|
2308
|
+
|
|
2309
|
+
var require$$1$1 = /*@__PURE__*/getAugmentedNamespace(urlStateMachine);
|
|
2310
|
+
|
|
2311
|
+
var _require$1 = require("./infra"),
|
|
2312
|
+
isASCIIHex = _require$1.isASCIIHex;
|
|
2313
|
+
var _require2 = require("./encoding"),
|
|
2314
|
+
utf8Encode = _require2.utf8Encode;
|
|
2315
|
+
function p$1(_char) {
|
|
2316
|
+
return _char.codePointAt(0);
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
// https://url.spec.whatwg.org/#percent-encode
|
|
2320
|
+
function percentEncode(c) {
|
|
2321
|
+
var hex = c.toString(16).toUpperCase();
|
|
2322
|
+
if (hex.length === 1) {
|
|
2323
|
+
hex = "0".concat(hex);
|
|
2324
|
+
}
|
|
2325
|
+
return "%".concat(hex);
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
// https://url.spec.whatwg.org/#percent-decode
|
|
2329
|
+
function percentDecodeBytes(input) {
|
|
2330
|
+
var output = new Uint8Array(input.byteLength);
|
|
2331
|
+
var outputIndex = 0;
|
|
2332
|
+
for (var i = 0; i < input.byteLength; ++i) {
|
|
2333
|
+
var _byte = input[i];
|
|
2334
|
+
if (_byte !== 0x25) {
|
|
2335
|
+
output[outputIndex++] = _byte;
|
|
2336
|
+
} else if (_byte === 0x25 && (!isASCIIHex(input[i + 1]) || !isASCIIHex(input[i + 2]))) {
|
|
2337
|
+
output[outputIndex++] = _byte;
|
|
2338
|
+
} else {
|
|
2339
|
+
var bytePoint = parseInt(String.fromCodePoint(input[i + 1], input[i + 2]), 16);
|
|
2340
|
+
output[outputIndex++] = bytePoint;
|
|
2341
|
+
i += 2;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
return output.slice(0, outputIndex);
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2347
|
+
// https://url.spec.whatwg.org/#string-percent-decode
|
|
2348
|
+
function percentDecodeString(input) {
|
|
2349
|
+
var bytes = utf8Encode(input);
|
|
2350
|
+
return percentDecodeBytes(bytes);
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
// https://url.spec.whatwg.org/#c0-control-percent-encode-set
|
|
2354
|
+
function isC0ControlPercentEncode(c) {
|
|
2355
|
+
return c <= 0x1F || c > 0x7E;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
// https://url.spec.whatwg.org/#fragment-percent-encode-set
|
|
2359
|
+
var extraFragmentPercentEncodeSet = new Set([p$1(" "), p$1("\""), p$1("<"), p$1(">"), p$1("`")]);
|
|
2360
|
+
function isFragmentPercentEncode(c) {
|
|
2361
|
+
return isC0ControlPercentEncode(c) || extraFragmentPercentEncodeSet.has(c);
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
// https://url.spec.whatwg.org/#query-percent-encode-set
|
|
2365
|
+
var extraQueryPercentEncodeSet = new Set([p$1(" "), p$1("\""), p$1("#"), p$1("<"), p$1(">")]);
|
|
2366
|
+
var extraQueryPercentEncodeChars = String.fromCodePoint.apply(String, _toConsumableArray(_toConsumableArray(extraQueryPercentEncodeSet).sort()));
|
|
2367
|
+
function isQueryPercentEncode(c) {
|
|
2368
|
+
return isC0ControlPercentEncode(c) || extraQueryPercentEncodeSet.has(c);
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
// https://url.spec.whatwg.org/#special-query-percent-encode-set
|
|
2372
|
+
var extraSpecialQueryPercentEncodeSet = new Set([].concat(_toConsumableArray(extraQueryPercentEncodeSet), [p$1("'")]));
|
|
2373
|
+
var extraSpecialQueryPercentEncodeChars = String.fromCodePoint.apply(String, _toConsumableArray(_toConsumableArray(extraSpecialQueryPercentEncodeSet).sort()));
|
|
2374
|
+
function isSpecialQueryPercentEncode(c) {
|
|
2375
|
+
return isC0ControlPercentEncode(c) || extraSpecialQueryPercentEncodeSet.has(c);
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
// https://url.spec.whatwg.org/#path-percent-encode-set
|
|
2379
|
+
var extraPathPercentEncodeSet = new Set([p$1("?"), p$1("`"), p$1("{"), p$1("}"), p$1("^")]);
|
|
2380
|
+
function isPathPercentEncode(c) {
|
|
2381
|
+
return isQueryPercentEncode(c) || extraPathPercentEncodeSet.has(c);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
// https://url.spec.whatwg.org/#userinfo-percent-encode-set
|
|
2385
|
+
var extraUserinfoPercentEncodeSet = new Set([p$1("/"), p$1(":"), p$1(";"), p$1("="), p$1("@"), p$1("["), p$1("\\"), p$1("]"), p$1("|")]);
|
|
2386
|
+
function isUserinfoPercentEncode(c) {
|
|
2387
|
+
return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c);
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
// https://url.spec.whatwg.org/#component-percent-encode-set
|
|
2391
|
+
var extraComponentPercentEncodeSet = new Set([p$1("$"), p$1("%"), p$1("&"), p$1("+"), p$1(",")]);
|
|
2392
|
+
function isComponentPercentEncode(c) {
|
|
2393
|
+
return isUserinfoPercentEncode(c) || extraComponentPercentEncodeSet.has(c);
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
// https://url.spec.whatwg.org/#application-x-www-form-urlencoded-percent-encode-set
|
|
2397
|
+
var extraURLEncodedPercentEncodeSet = new Set([p$1("!"), p$1("'"), p$1("("), p$1(")"), p$1("~")]);
|
|
2398
|
+
function isURLEncodedPercentEncode(c) {
|
|
2399
|
+
return isComponentPercentEncode(c) || extraURLEncodedPercentEncodeSet.has(c);
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
// https://url.spec.whatwg.org/#code-point-percent-encode-after-encoding
|
|
2403
|
+
// https://url.spec.whatwg.org/#utf-8-percent-encode
|
|
2404
|
+
// Assuming encoding is always utf-8 allows us to trim one of the logic branches. TODO: support encoding.
|
|
2405
|
+
// The "-Internal" variant here has code points as JS strings. The external version used by other files has code points
|
|
2406
|
+
// as JS numbers, like the rest of the codebase.
|
|
2407
|
+
function utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate) {
|
|
2408
|
+
var bytes = utf8Encode(codePoint);
|
|
2409
|
+
var output = "";
|
|
2410
|
+
var _iterator = _createForOfIteratorHelper(bytes),
|
|
2411
|
+
_step;
|
|
2412
|
+
try {
|
|
2413
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2414
|
+
var _byte2 = _step.value;
|
|
2415
|
+
// Our percentEncodePredicate operates on bytes, not code points, so this is slightly different from the spec.
|
|
2416
|
+
if (!percentEncodePredicate(_byte2)) {
|
|
2417
|
+
output += String.fromCharCode(_byte2);
|
|
2418
|
+
} else {
|
|
2419
|
+
output += percentEncode(_byte2);
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
} catch (err) {
|
|
2423
|
+
_iterator.e(err);
|
|
2424
|
+
} finally {
|
|
2425
|
+
_iterator.f();
|
|
2426
|
+
}
|
|
2427
|
+
return output;
|
|
2428
|
+
}
|
|
2429
|
+
function utf8PercentEncodeCodePoint(codePoint, percentEncodePredicate) {
|
|
2430
|
+
return utf8PercentEncodeCodePointInternal(String.fromCodePoint(codePoint), percentEncodePredicate);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
// https://url.spec.whatwg.org/#string-percent-encode-after-encoding
|
|
2434
|
+
// https://url.spec.whatwg.org/#string-utf-8-percent-encode
|
|
2435
|
+
function utf8PercentEncodeString(input, percentEncodePredicate) {
|
|
2436
|
+
var spaceAsPlus = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
2437
|
+
var output = "";
|
|
2438
|
+
var _iterator2 = _createForOfIteratorHelper(input),
|
|
2439
|
+
_step2;
|
|
2440
|
+
try {
|
|
2441
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2442
|
+
var codePoint = _step2.value;
|
|
2443
|
+
if (spaceAsPlus && codePoint === " ") {
|
|
2444
|
+
output += "+";
|
|
2445
|
+
} else {
|
|
2446
|
+
output += utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate);
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
} catch (err) {
|
|
2450
|
+
_iterator2.e(err);
|
|
2451
|
+
} finally {
|
|
2452
|
+
_iterator2.f();
|
|
2453
|
+
}
|
|
2454
|
+
return output;
|
|
2455
|
+
}
|
|
2456
|
+
module.exports = {
|
|
2457
|
+
isC0ControlPercentEncode: isC0ControlPercentEncode,
|
|
2458
|
+
isFragmentPercentEncode: isFragmentPercentEncode,
|
|
2459
|
+
isQueryPercentEncode: isQueryPercentEncode,
|
|
2460
|
+
isSpecialQueryPercentEncode: isSpecialQueryPercentEncode,
|
|
2461
|
+
isPathPercentEncode: isPathPercentEncode,
|
|
2462
|
+
isUserinfoPercentEncode: isUserinfoPercentEncode,
|
|
2463
|
+
isURLEncodedPercentEncode: isURLEncodedPercentEncode,
|
|
2464
|
+
extraQueryPercentEncodeChars: extraQueryPercentEncodeChars,
|
|
2465
|
+
extraSpecialQueryPercentEncodeChars: extraSpecialQueryPercentEncodeChars,
|
|
2466
|
+
percentDecodeString: percentDecodeString,
|
|
2467
|
+
percentDecodeBytes: percentDecodeBytes,
|
|
2468
|
+
utf8PercentEncodeString: utf8PercentEncodeString,
|
|
2469
|
+
utf8PercentEncodeCodePoint: utf8PercentEncodeCodePoint
|
|
2470
|
+
};
|
|
2471
|
+
|
|
2472
|
+
var percentEncoding = /*#__PURE__*/Object.freeze({
|
|
2473
|
+
__proto__: null
|
|
2474
|
+
});
|
|
2475
|
+
|
|
2476
|
+
var require$$2 = /*@__PURE__*/getAugmentedNamespace(percentEncoding);
|
|
2477
|
+
|
|
2478
|
+
var infra$1;
|
|
2479
|
+
var hasRequiredInfra;
|
|
2480
|
+
|
|
2481
|
+
function requireInfra () {
|
|
2482
|
+
if (hasRequiredInfra) return infra$1;
|
|
2483
|
+
hasRequiredInfra = 1;
|
|
2484
|
+
|
|
2485
|
+
// Note that we take code points as JS numbers, not JS strings.
|
|
2486
|
+
function isASCIIDigit(c) {
|
|
2487
|
+
return c >= 0x30 && c <= 0x39;
|
|
2488
|
+
}
|
|
2489
|
+
function isASCIIAlpha(c) {
|
|
2490
|
+
return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A;
|
|
2491
|
+
}
|
|
2492
|
+
function isASCIIAlphanumeric(c) {
|
|
2493
|
+
return isASCIIAlpha(c) || isASCIIDigit(c);
|
|
2494
|
+
}
|
|
2495
|
+
function isASCIIHex(c) {
|
|
2496
|
+
return isASCIIDigit(c) || c >= 0x41 && c <= 0x46 || c >= 0x61 && c <= 0x66;
|
|
2497
|
+
}
|
|
2498
|
+
function isASCIIString(string) {
|
|
2499
|
+
return !/(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/.test(string);
|
|
2500
|
+
}
|
|
2501
|
+
function isNoncharacter(c) {
|
|
2502
|
+
return c >= 0xFDD0 && c <= 0xFDEF || (c & 0xFFFE) === 0xFFFE;
|
|
2503
|
+
}
|
|
2504
|
+
infra$1 = {
|
|
2505
|
+
isASCIIDigit: isASCIIDigit,
|
|
2506
|
+
isASCIIAlpha: isASCIIAlpha,
|
|
2507
|
+
isASCIIAlphanumeric: isASCIIAlphanumeric,
|
|
2508
|
+
isASCIIHex: isASCIIHex,
|
|
2509
|
+
isASCIIString: isASCIIString,
|
|
2510
|
+
isNoncharacter: isNoncharacter
|
|
2511
|
+
};
|
|
2512
|
+
return infra$1;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
var tr46 = require("tr46");
|
|
2516
|
+
var infra = require("./infra");
|
|
2517
|
+
function p(_char) {
|
|
2518
|
+
return _char.codePointAt(0);
|
|
2519
|
+
}
|
|
2520
|
+
var failure = Symbol("failure");
|
|
2521
|
+
var specialSchemes = {
|
|
2522
|
+
ftp: 21,
|
|
2523
|
+
file: null,
|
|
2524
|
+
http: 80,
|
|
2525
|
+
https: 443,
|
|
2526
|
+
ws: 80,
|
|
2527
|
+
wss: 443
|
|
2528
|
+
};
|
|
2529
|
+
var urlCodePoints = new Set([p("!"), p("$"), p("&"), p("'"), p("("), p(")"), p("*"), p("+"), p(","), p("-"), p("."), p("/"), p(":"), p(";"), p("="), p("?"), p("@"), p("_"), p("~")]);
|
|
2530
|
+
var forbiddenHostCodePoints = new Set([0x00, 0x09, 0x0A, 0x0D, 0x20, p("#"), p("/"), p(":"), p("<"), p(">"), p("?"), p("@"), p("["), p("\\"), p("]"), p("^"), p("|")]);
|
|
2531
|
+
function isURLCodePoint(c) {
|
|
2532
|
+
return infra.isASCIIAlphanumeric(c) || urlCodePoints.has(c) || c >= 0xA0 && c <= 0x10FFFD && (c < 0xD800 || c > 0xDFFF) && !infra.isNoncharacter(c);
|
|
2533
|
+
}
|
|
2534
|
+
function isInvalidURLCodePoint(c) {
|
|
2535
|
+
return !isURLCodePoint(c) && c !== p("%");
|
|
2536
|
+
}
|
|
2537
|
+
function isPercentEncodedByteAt(input, index) {
|
|
2538
|
+
return index + 2 < input.length && input[index] === "%" && infra.isASCIIHex(input.charCodeAt(index + 1)) && infra.isASCIIHex(input.charCodeAt(index + 2));
|
|
2539
|
+
}
|
|
2540
|
+
function containsPercentEncodedByte(input) {
|
|
2541
|
+
return /%[0-9A-Fa-f]{2}/.test(input);
|
|
2542
|
+
}
|
|
2543
|
+
function containsForbiddenHostCodePoint(string) {
|
|
2544
|
+
return _toConsumableArray(string).some(function (c) {
|
|
2545
|
+
return forbiddenHostCodePoints.has(c.codePointAt(0));
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2548
|
+
function containsForbiddenDomainCodePoint(string) {
|
|
2549
|
+
return _toConsumableArray(string).some(function (c) {
|
|
2550
|
+
var cp = c.codePointAt(0);
|
|
2551
|
+
return forbiddenHostCodePoints.has(cp) || cp >= 0x00 && cp <= 0x1F || cp === p("%") || cp === 0x7F;
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
function domainParserToASCII(domain, beStrict) {
|
|
2555
|
+
return tr46.toASCII(domain, {
|
|
2556
|
+
checkHyphens: beStrict,
|
|
2557
|
+
checkBidi: true,
|
|
2558
|
+
checkJoiners: true,
|
|
2559
|
+
useSTD3ASCIIRules: beStrict,
|
|
2560
|
+
transitionalProcessing: false,
|
|
2561
|
+
verifyDNSLength: beStrict,
|
|
2562
|
+
ignoreInvalidPunycode: false
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
function parseIPv4Number(input) {
|
|
2566
|
+
var validationErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
2567
|
+
if (input === "") {
|
|
2568
|
+
return failure;
|
|
2569
|
+
}
|
|
2570
|
+
var validationErrorSeen = false;
|
|
2571
|
+
var R = 10;
|
|
2572
|
+
if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") {
|
|
2573
|
+
validationErrorSeen = true;
|
|
2574
|
+
input = input.substring(2);
|
|
2575
|
+
R = 16;
|
|
2576
|
+
} else if (input.length >= 2 && input.charAt(0) === "0") {
|
|
2577
|
+
validationErrorSeen = true;
|
|
2578
|
+
input = input.substring(1);
|
|
2579
|
+
R = 8;
|
|
2580
|
+
}
|
|
2581
|
+
if (input === "") {
|
|
2582
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-non-decimal-part");
|
|
2583
|
+
return 0;
|
|
2584
|
+
}
|
|
2585
|
+
var regex = /(?:[\0-\/8-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/;
|
|
2586
|
+
if (R === 10) {
|
|
2587
|
+
regex = /(?:[\0-\/:-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/;
|
|
2588
|
+
}
|
|
2589
|
+
if (R === 16) {
|
|
2590
|
+
regex = /(?:[\0-\/:-@G-`g-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/;
|
|
2591
|
+
}
|
|
2592
|
+
if (regex.test(input)) {
|
|
2593
|
+
return failure;
|
|
2594
|
+
}
|
|
2595
|
+
if (validationErrorSeen) {
|
|
2596
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("IPv4-non-decimal-part");
|
|
2597
|
+
}
|
|
2598
|
+
return parseInt(input, R);
|
|
2599
|
+
}
|
|
2600
|
+
function endsInANumber(input) {
|
|
2601
|
+
var parts = input.split(".");
|
|
2602
|
+
if (parts[parts.length - 1] === "") {
|
|
2603
|
+
if (parts.length === 1) {
|
|
2604
|
+
return false;
|
|
2605
|
+
}
|
|
2606
|
+
parts.pop();
|
|
2607
|
+
}
|
|
2608
|
+
var last = parts[parts.length - 1];
|
|
2609
|
+
if (/^[0-9]+$/.test(last)) {
|
|
2610
|
+
return true;
|
|
2611
|
+
}
|
|
2612
|
+
if (parseIPv4Number(last) !== failure) {
|
|
2613
|
+
return true;
|
|
2614
|
+
}
|
|
2615
|
+
return false;
|
|
2616
|
+
}
|
|
2617
|
+
function domainParser(domain) {
|
|
2618
|
+
var validationErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
2619
|
+
var beStrict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
2620
|
+
// A domain-to-ASCII validation error is reported whenever the strict Unicode ToASCII (CheckHyphens,
|
|
2621
|
+
// UseSTD3ASCIIRules, and VerifyDnsLength all true) fails, even when the relaxed parameters used
|
|
2622
|
+
// for non-strict parsing succeed. This step does not itself fail the algorithm.
|
|
2623
|
+
//
|
|
2624
|
+
// Spec divergence (performance): the URL Standard runs this strict pass unconditionally, but when
|
|
2625
|
+
// beStrict is false its only effect is that validation error, so we skip it when we are neither
|
|
2626
|
+
// being strict nor collecting validation errors.
|
|
2627
|
+
if (beStrict || validationErrors) {
|
|
2628
|
+
var strictResult = domainParserToASCII(domain, true);
|
|
2629
|
+
if (strictResult === null) {
|
|
2630
|
+
validationErrors === null || validationErrors === void 0 || validationErrors.push("domain-to-ASCII");
|
|
2631
|
+
}
|
|
2632
|
+
if (beStrict) {
|
|
2633
|
+
return strictResult === null ? failure : strictResult;
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
var result;
|
|
2637
|
+
if (infra.isASCIIString(domain)) {
|
|
2638
|
+
// For web compatibility an ASCII domain is returned lowercased regardless of ToASCII's outcome.
|
|
2639
|
+
result = domain.toLowerCase();
|
|
2640
|
+
} else {
|
|
2641
|
+
result = domainParserToASCII(domain, false);
|
|
2642
|
+
if (result === null) {
|
|
2643
|
+
return failure;
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
if (result === "") {
|
|
2647
|
+
return failure;
|
|
2648
|
+
}
|
|
2649
|
+
if (containsForbiddenDomainCodePoint(result)) {
|
|
2650
|
+
return failure;
|
|
2651
|
+
}
|
|
2652
|
+
return result;
|
|
2653
|
+
}
|
|
2654
|
+
function isSpecialScheme(scheme) {
|
|
2655
|
+
return specialSchemes[scheme.toLowerCase()] !== undefined;
|
|
2656
|
+
}
|
|
2657
|
+
function isSpecialSchemeExceptFile(scheme) {
|
|
2658
|
+
return isSpecialScheme(scheme) && scheme.toLowerCase() !== "file";
|
|
2659
|
+
}
|
|
2660
|
+
function defaultPort(scheme) {
|
|
2661
|
+
return specialSchemes[scheme.toLowerCase()];
|
|
2662
|
+
}
|
|
2663
|
+
function isWindowsDriveLetterCodePoints(cp1, cp2) {
|
|
2664
|
+
return infra.isASCIIAlpha(cp1) && (cp2 === p(":") || cp2 === p("|"));
|
|
2665
|
+
}
|
|
2666
|
+
function isWindowsDriveLetterString(string) {
|
|
2667
|
+
return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|");
|
|
2668
|
+
}
|
|
2669
|
+
function isNormalizedWindowsDriveLetterString(string) {
|
|
2670
|
+
return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && string[1] === ":";
|
|
2671
|
+
}
|
|
2672
|
+
module.exports = {
|
|
2673
|
+
containsForbiddenHostCodePoint: containsForbiddenHostCodePoint,
|
|
2674
|
+
containsPercentEncodedByte: containsPercentEncodedByte,
|
|
2675
|
+
defaultPort: defaultPort,
|
|
2676
|
+
domainParser: domainParser,
|
|
2677
|
+
endsInANumber: endsInANumber,
|
|
2678
|
+
failure: failure,
|
|
2679
|
+
forbiddenHostCodePoints: forbiddenHostCodePoints,
|
|
2680
|
+
isInvalidURLCodePoint: isInvalidURLCodePoint,
|
|
2681
|
+
isNormalizedWindowsDriveLetterString: isNormalizedWindowsDriveLetterString,
|
|
2682
|
+
isPercentEncodedByteAt: isPercentEncodedByteAt,
|
|
2683
|
+
parseIPv4Number: parseIPv4Number,
|
|
2684
|
+
isSpecialScheme: isSpecialScheme,
|
|
2685
|
+
isSpecialSchemeExceptFile: isSpecialSchemeExceptFile,
|
|
2686
|
+
isURLCodePoint: isURLCodePoint,
|
|
2687
|
+
isWindowsDriveLetterCodePoints: isWindowsDriveLetterCodePoints,
|
|
2688
|
+
isWindowsDriveLetterString: isWindowsDriveLetterString,
|
|
2689
|
+
p: p
|
|
2690
|
+
};
|
|
2691
|
+
|
|
2692
|
+
var urlMiscellaneous = /*#__PURE__*/Object.freeze({
|
|
2693
|
+
__proto__: null
|
|
2694
|
+
});
|
|
2695
|
+
|
|
2696
|
+
var require$$1 = /*@__PURE__*/getAugmentedNamespace(urlMiscellaneous);
|
|
2697
|
+
|
|
2698
|
+
var urlStringValidator;
|
|
2699
|
+
var hasRequiredUrlStringValidator;
|
|
2700
|
+
|
|
2701
|
+
function requireUrlStringValidator () {
|
|
2702
|
+
if (hasRequiredUrlStringValidator) return urlStringValidator;
|
|
2703
|
+
hasRequiredUrlStringValidator = 1;
|
|
2704
|
+
|
|
2705
|
+
var infra = requireInfra();
|
|
2706
|
+
var _require = require$$1,
|
|
2707
|
+
domainParser = _require.domainParser,
|
|
2708
|
+
endsInANumber = _require.endsInANumber,
|
|
2709
|
+
failure = _require.failure,
|
|
2710
|
+
forbiddenHostCodePoints = _require.forbiddenHostCodePoints,
|
|
2711
|
+
isPercentEncodedByteAt = _require.isPercentEncodedByteAt,
|
|
2712
|
+
isSpecialSchemeExceptFile = _require.isSpecialSchemeExceptFile,
|
|
2713
|
+
isURLCodePoint = _require.isURLCodePoint,
|
|
2714
|
+
p = _require.p;
|
|
2715
|
+
var _require2 = require$$1$1,
|
|
2716
|
+
hasAnOpaquePath = _require2.hasAnOpaquePath;
|
|
2717
|
+
var pathSegmentExcludedCodePoints = new Set([p("/"), p("?")]);
|
|
2718
|
+
var opaquePathExcludedCodePoints = new Set([p("?")]);
|
|
2719
|
+
function splitOffFragment(input) {
|
|
2720
|
+
var fragmentStart = input.indexOf("#");
|
|
2721
|
+
if (fragmentStart === -1) {
|
|
2722
|
+
return {
|
|
2723
|
+
beforeFragment: input,
|
|
2724
|
+
fragment: null
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2727
|
+
return {
|
|
2728
|
+
beforeFragment: input.substring(0, fragmentStart),
|
|
2729
|
+
fragment: input.substring(fragmentStart + 1)
|
|
2730
|
+
};
|
|
2731
|
+
}
|
|
2732
|
+
function splitOffQuery(input) {
|
|
2733
|
+
var queryStart = input.indexOf("?");
|
|
2734
|
+
if (queryStart === -1) {
|
|
2735
|
+
return {
|
|
2736
|
+
beforeQuery: input,
|
|
2737
|
+
query: null
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2740
|
+
return {
|
|
2741
|
+
beforeQuery: input.substring(0, queryStart),
|
|
2742
|
+
query: input.substring(queryStart + 1)
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
function isValidURLString(input) {
|
|
2746
|
+
var _options$baseURL;
|
|
2747
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2748
|
+
var baseURL = (_options$baseURL = options.baseURL) !== null && _options$baseURL !== void 0 ? _options$baseURL : null;
|
|
2749
|
+
return isValidAbsoluteURLWithFragmentString(input) || baseURL !== null && isValidRelativeURLWithFragmentString(input, baseURL);
|
|
2750
|
+
}
|
|
2751
|
+
function isValidAbsoluteURLWithFragmentString(input) {
|
|
2752
|
+
var _splitOffFragment = splitOffFragment(input),
|
|
2753
|
+
beforeFragment = _splitOffFragment.beforeFragment,
|
|
2754
|
+
fragment = _splitOffFragment.fragment;
|
|
2755
|
+
return (fragment === null || isValidURLFragmentString(fragment)) && isValidAbsoluteURLString(beforeFragment);
|
|
2756
|
+
}
|
|
2757
|
+
function isValidAbsoluteURLString(input) {
|
|
2758
|
+
var _splitOffQuery = splitOffQuery(input),
|
|
2759
|
+
beforeQuery = _splitOffQuery.beforeQuery,
|
|
2760
|
+
query = _splitOffQuery.query;
|
|
2761
|
+
if (query !== null && !isValidURLQueryString(query)) {
|
|
2762
|
+
return false;
|
|
2763
|
+
}
|
|
2764
|
+
var schemeMatch = /^([A-Za-z][\+\x2D\.0-9A-Za-z]*):/.exec(beforeQuery);
|
|
2765
|
+
if (schemeMatch === null) {
|
|
2766
|
+
return false;
|
|
2767
|
+
}
|
|
2768
|
+
var scheme = schemeMatch[1].toLowerCase();
|
|
2769
|
+
var afterScheme = beforeQuery.substring(schemeMatch[0].length);
|
|
2770
|
+
if (isSpecialSchemeExceptFile(scheme)) {
|
|
2771
|
+
return isValidSchemeRelativeSpecialURLString(afterScheme);
|
|
2772
|
+
}
|
|
2773
|
+
if (scheme === "file") {
|
|
2774
|
+
return isValidSchemeRelativeFileURLString(afterScheme);
|
|
2775
|
+
}
|
|
2776
|
+
return isValidSchemeRelativeURLString(afterScheme) || isValidPathAbsoluteNonAuthorityURLString(afterScheme) || isValidOpaquePathURLString(afterScheme);
|
|
2777
|
+
}
|
|
2778
|
+
function isValidRelativeURLWithFragmentString(input, baseURL) {
|
|
2779
|
+
if (hasAnOpaquePath(baseURL)) {
|
|
2780
|
+
return input.startsWith("#") && isValidURLFragmentString(input.substring(1));
|
|
2781
|
+
}
|
|
2782
|
+
var _splitOffFragment2 = splitOffFragment(input),
|
|
2783
|
+
beforeFragment = _splitOffFragment2.beforeFragment,
|
|
2784
|
+
fragment = _splitOffFragment2.fragment;
|
|
2785
|
+
return isValidRelativeURLString(beforeFragment, baseURL) && (fragment === null || isValidURLFragmentString(fragment));
|
|
2786
|
+
}
|
|
2787
|
+
function isValidRelativeURLString(input, baseURL) {
|
|
2788
|
+
var _splitOffQuery2 = splitOffQuery(input),
|
|
2789
|
+
beforeQuery = _splitOffQuery2.beforeQuery,
|
|
2790
|
+
query = _splitOffQuery2.query;
|
|
2791
|
+
var hasValidQuery = query === null || isValidURLQueryString(query);
|
|
2792
|
+
if (isValidPathAbsoluteNonAuthorityURLString(beforeQuery)) {
|
|
2793
|
+
return hasValidQuery;
|
|
2794
|
+
}
|
|
2795
|
+
if (isValidPathRelativeSchemeLessURLString(beforeQuery)) {
|
|
2796
|
+
return hasValidQuery;
|
|
2797
|
+
}
|
|
2798
|
+
if (isSpecialSchemeExceptFile(baseURL.scheme)) {
|
|
2799
|
+
return isValidSchemeRelativeSpecialURLString(beforeQuery) && hasValidQuery;
|
|
2800
|
+
}
|
|
2801
|
+
if (baseURL.scheme === "file") {
|
|
2802
|
+
return isValidSchemeRelativeFileURLString(beforeQuery) && hasValidQuery;
|
|
2803
|
+
}
|
|
2804
|
+
return isValidSchemeRelativeURLString(beforeQuery) && hasValidQuery;
|
|
2805
|
+
}
|
|
2806
|
+
function isValidSchemeRelativeSpecialURLString(input) {
|
|
2807
|
+
if (!input.startsWith("//")) {
|
|
2808
|
+
return false;
|
|
2809
|
+
}
|
|
2810
|
+
var _splitOffPath = splitOffPath(input.substring(2)),
|
|
2811
|
+
authority = _splitOffPath.authority,
|
|
2812
|
+
path = _splitOffPath.path;
|
|
2813
|
+
return isValidHostAndPortString(authority, isValidHostString) && (path === null || isValidPathAbsoluteURLString(path));
|
|
2814
|
+
}
|
|
2815
|
+
function isValidSchemeRelativeURLString(input) {
|
|
2816
|
+
if (!input.startsWith("//")) {
|
|
2817
|
+
return false;
|
|
2818
|
+
}
|
|
2819
|
+
var _splitOffPath2 = splitOffPath(input.substring(2)),
|
|
2820
|
+
authority = _splitOffPath2.authority,
|
|
2821
|
+
path = _splitOffPath2.path;
|
|
2822
|
+
return isValidOpaqueHostAndPortString(authority) && (path === null || isValidPathAbsoluteURLString(path));
|
|
2823
|
+
}
|
|
2824
|
+
function isValidSchemeRelativeFileURLString(input) {
|
|
2825
|
+
if (!input.startsWith("//")) {
|
|
2826
|
+
return false;
|
|
2827
|
+
}
|
|
2828
|
+
var afterSlashes = input.substring(2);
|
|
2829
|
+
return afterSlashes === "" || isValidHostAndPathAbsoluteURLString(afterSlashes) || isValidPathAbsoluteURLString(afterSlashes);
|
|
2830
|
+
}
|
|
2831
|
+
function isValidHostAndPathAbsoluteURLString(input) {
|
|
2832
|
+
var _splitOffPath3 = splitOffPath(input),
|
|
2833
|
+
authority = _splitOffPath3.authority,
|
|
2834
|
+
path = _splitOffPath3.path;
|
|
2835
|
+
return isValidHostString(authority) && (path === null || isValidPathAbsoluteURLString(path));
|
|
2836
|
+
}
|
|
2837
|
+
function splitOffPath(input) {
|
|
2838
|
+
var pathStart = input.indexOf("/");
|
|
2839
|
+
if (pathStart === -1) {
|
|
2840
|
+
return {
|
|
2841
|
+
authority: input,
|
|
2842
|
+
path: null
|
|
2843
|
+
};
|
|
2844
|
+
}
|
|
2845
|
+
return {
|
|
2846
|
+
authority: input.substring(0, pathStart),
|
|
2847
|
+
path: input.substring(pathStart)
|
|
2848
|
+
};
|
|
2849
|
+
}
|
|
2850
|
+
function isValidHostAndPortString(input, isValidHost) {
|
|
2851
|
+
var parsed = splitHostAndPort(input);
|
|
2852
|
+
return parsed !== null && parsed.host !== "" && isValidHost(parsed.host) && (parsed.port === null || isValidURLPortString(parsed.port));
|
|
2853
|
+
}
|
|
2854
|
+
function isValidOpaqueHostAndPortString(input) {
|
|
2855
|
+
if (input === "") {
|
|
2856
|
+
return true;
|
|
2857
|
+
}
|
|
2858
|
+
var parsed = splitHostAndPort(input);
|
|
2859
|
+
return parsed !== null && parsed.host !== "" && isValidOpaqueHostString(parsed.host) && (parsed.port === null || isValidURLPortString(parsed.port));
|
|
2860
|
+
}
|
|
2861
|
+
function splitHostAndPort(input) {
|
|
2862
|
+
if (input.startsWith("[")) {
|
|
2863
|
+
var hostEnd = input.indexOf("]");
|
|
2864
|
+
if (hostEnd === -1) {
|
|
2865
|
+
return null;
|
|
2866
|
+
}
|
|
2867
|
+
var rest = input.substring(hostEnd + 1);
|
|
2868
|
+
if (rest !== "" && !rest.startsWith(":")) {
|
|
2869
|
+
return null;
|
|
2870
|
+
}
|
|
2871
|
+
return {
|
|
2872
|
+
host: input.substring(0, hostEnd + 1),
|
|
2873
|
+
port: rest === "" ? null : rest.substring(1)
|
|
2874
|
+
};
|
|
2875
|
+
}
|
|
2876
|
+
var portStart = input.indexOf(":");
|
|
2877
|
+
if (portStart === -1) {
|
|
2878
|
+
return {
|
|
2879
|
+
host: input,
|
|
2880
|
+
port: null
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
return {
|
|
2884
|
+
host: input.substring(0, portStart),
|
|
2885
|
+
port: input.substring(portStart + 1)
|
|
2886
|
+
};
|
|
2887
|
+
}
|
|
2888
|
+
function isValidHostString(input) {
|
|
2889
|
+
return isValidDomainString(input) || isValidIPv4AddressString(input) || isValidBracketedIPv6AddressString(input);
|
|
2890
|
+
}
|
|
2891
|
+
function isValidDomainString(input) {
|
|
2892
|
+
var domain = domainParser(input, null, true);
|
|
2893
|
+
return domain !== failure && !endsInANumber(domain);
|
|
2894
|
+
}
|
|
2895
|
+
function isValidIPv4AddressString(input) {
|
|
2896
|
+
var pieces = input.split(".");
|
|
2897
|
+
return pieces.length === 4 && pieces.every(isValidIPv4AddressPieceString);
|
|
2898
|
+
}
|
|
2899
|
+
function isValidIPv4AddressPieceString(input) {
|
|
2900
|
+
if (input === "" || input.length > 3) {
|
|
2901
|
+
return false;
|
|
2902
|
+
}
|
|
2903
|
+
for (var i = 0; i < input.length; ++i) {
|
|
2904
|
+
if (!infra.isASCIIDigit(input.codePointAt(i))) {
|
|
2905
|
+
return false;
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
if (input.length > 1 && input[0] === "0") {
|
|
2909
|
+
return false;
|
|
2910
|
+
}
|
|
2911
|
+
return Number(input) <= 255;
|
|
2912
|
+
}
|
|
2913
|
+
function isValidBracketedIPv6AddressString(input) {
|
|
2914
|
+
return input.startsWith("[") && input.endsWith("]") && isValidIPv6AddressString(input.substring(1, input.length - 1));
|
|
2915
|
+
}
|
|
2916
|
+
function isValidIPv6AddressString(input) {
|
|
2917
|
+
return getIPv6PiecesStringEffectiveLength(input) === 8 || getIPv6PiecesAndIPv4StringEffectiveLength(input) === 8 || isValidCompressedIPv6AddressString(input);
|
|
2918
|
+
}
|
|
2919
|
+
function isValidCompressedIPv6AddressString(input) {
|
|
2920
|
+
var compressionIndex = input.indexOf("::");
|
|
2921
|
+
if (compressionIndex === -1 || compressionIndex !== input.lastIndexOf("::")) {
|
|
2922
|
+
return false;
|
|
2923
|
+
}
|
|
2924
|
+
var preceding = input.substring(0, compressionIndex);
|
|
2925
|
+
var following = input.substring(compressionIndex + 2);
|
|
2926
|
+
var precedingLength = getOptionalIPv6PiecesStringEffectiveLength(preceding);
|
|
2927
|
+
var followingLength = getOptionalIPv6PiecesOrPiecesAndIPv4StringEffectiveLength(following);
|
|
2928
|
+
if (precedingLength === failure || followingLength === failure) {
|
|
2929
|
+
return false;
|
|
2930
|
+
}
|
|
2931
|
+
return precedingLength + followingLength <= 7;
|
|
2932
|
+
}
|
|
2933
|
+
function getOptionalIPv6PiecesStringEffectiveLength(input) {
|
|
2934
|
+
return input === "" ? 0 : getIPv6PiecesStringEffectiveLength(input);
|
|
2935
|
+
}
|
|
2936
|
+
function getOptionalIPv6PiecesOrPiecesAndIPv4StringEffectiveLength(input) {
|
|
2937
|
+
return input === "" ? 0 : getIPv6PiecesOrPiecesAndIPv4StringEffectiveLength(input);
|
|
2938
|
+
}
|
|
2939
|
+
function getIPv6PiecesOrPiecesAndIPv4StringEffectiveLength(input) {
|
|
2940
|
+
if (isValidIPv6PiecesString(input)) {
|
|
2941
|
+
return getIPv6PiecesStringEffectiveLength(input);
|
|
2942
|
+
}
|
|
2943
|
+
if (isValidIPv6PiecesAndIPv4String(input)) {
|
|
2944
|
+
return getIPv6PiecesAndIPv4StringEffectiveLength(input);
|
|
2945
|
+
}
|
|
2946
|
+
return failure;
|
|
2947
|
+
}
|
|
2948
|
+
function isValidIPv6PiecesAndIPv4String(input) {
|
|
2949
|
+
if (isValidIPv4AddressString(input)) {
|
|
2950
|
+
return true;
|
|
2951
|
+
}
|
|
2952
|
+
var ipv4SeparatorIndex = input.lastIndexOf(":");
|
|
2953
|
+
if (ipv4SeparatorIndex === -1) {
|
|
2954
|
+
return false;
|
|
2955
|
+
}
|
|
2956
|
+
return isValidIPv6PiecesString(input.substring(0, ipv4SeparatorIndex)) && isValidIPv4AddressString(input.substring(ipv4SeparatorIndex + 1));
|
|
2957
|
+
}
|
|
2958
|
+
function getIPv6PiecesAndIPv4StringEffectiveLength(input) {
|
|
2959
|
+
if (!isValidIPv6PiecesAndIPv4String(input)) {
|
|
2960
|
+
return failure;
|
|
2961
|
+
}
|
|
2962
|
+
var ipv4SeparatorIndex = input.lastIndexOf(":");
|
|
2963
|
+
if (ipv4SeparatorIndex === -1) {
|
|
2964
|
+
return 2;
|
|
2965
|
+
}
|
|
2966
|
+
var piecesLength = getIPv6PiecesStringEffectiveLength(input.substring(0, ipv4SeparatorIndex));
|
|
2967
|
+
return piecesLength + 2;
|
|
2968
|
+
}
|
|
2969
|
+
function isValidIPv6PiecesString(input) {
|
|
2970
|
+
if (input === "") {
|
|
2971
|
+
return false;
|
|
2972
|
+
}
|
|
2973
|
+
var pieces = input.split(":");
|
|
2974
|
+
return pieces.every(isValidIPv6PieceString);
|
|
2975
|
+
}
|
|
2976
|
+
function getIPv6PiecesStringEffectiveLength(input) {
|
|
2977
|
+
return isValidIPv6PiecesString(input) ? input.split(":").length : failure;
|
|
2978
|
+
}
|
|
2979
|
+
function isValidIPv6PieceString(input) {
|
|
2980
|
+
if (input === "" || input.length > 4) {
|
|
2981
|
+
return false;
|
|
2982
|
+
}
|
|
2983
|
+
for (var i = 0; i < input.length; ++i) {
|
|
2984
|
+
if (!infra.isASCIIHex(input.codePointAt(i))) {
|
|
2985
|
+
return false;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
var value = parseInt(input, 16);
|
|
2989
|
+
return value <= 0xFFFF && (input.length === 1 || input[0] !== "0");
|
|
2990
|
+
}
|
|
2991
|
+
function isValidOpaqueHostString(input) {
|
|
2992
|
+
return isValidBracketedIPv6AddressString(input) || input !== "" && isValidURLUnits(input, forbiddenHostCodePoints);
|
|
2993
|
+
}
|
|
2994
|
+
function isValidURLPortString(input) {
|
|
2995
|
+
if (input === "") {
|
|
2996
|
+
return true;
|
|
2997
|
+
}
|
|
2998
|
+
if (!/^[0-9]+$/.test(input)) {
|
|
2999
|
+
return false;
|
|
3000
|
+
}
|
|
3001
|
+
return Number(input) <= 65535;
|
|
3002
|
+
}
|
|
3003
|
+
function isValidPathAbsoluteURLString(input) {
|
|
3004
|
+
return input.startsWith("/") && input.substring(1).split("/").every(isValidURLPathSegmentString);
|
|
3005
|
+
}
|
|
3006
|
+
function isValidPathAbsoluteNonAuthorityURLString(input) {
|
|
3007
|
+
return isValidPathAbsoluteURLString(input) && !input.startsWith("//");
|
|
3008
|
+
}
|
|
3009
|
+
function isValidPathRelativeURLString(input) {
|
|
3010
|
+
return !input.startsWith("/") && input.split("/").every(isValidURLPathSegmentString);
|
|
3011
|
+
}
|
|
3012
|
+
function isValidURLPathSegmentString(input) {
|
|
3013
|
+
return isValidURLUnits(input, pathSegmentExcludedCodePoints);
|
|
3014
|
+
}
|
|
3015
|
+
function isValidPathRelativeSchemeLessURLString(input) {
|
|
3016
|
+
return isValidPathRelativeURLString(input) && !/^[A-Za-z][\+\x2D\.0-9A-Za-z]*:/.test(input);
|
|
3017
|
+
}
|
|
3018
|
+
function isValidOpaquePathURLString(input) {
|
|
3019
|
+
return (input === "" || input[0] !== "/") && isValidURLUnits(input, opaquePathExcludedCodePoints);
|
|
3020
|
+
}
|
|
3021
|
+
function isValidURLQueryString(input) {
|
|
3022
|
+
return isValidURLUnits(input);
|
|
3023
|
+
}
|
|
3024
|
+
function isValidURLFragmentString(input) {
|
|
3025
|
+
return isValidURLUnits(input);
|
|
3026
|
+
}
|
|
3027
|
+
function isValidURLUnits(input) {
|
|
3028
|
+
var excludedCodePoints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
|
|
3029
|
+
for (var i = 0; i < input.length;) {
|
|
3030
|
+
if (input[i] === "%") {
|
|
3031
|
+
if (!isPercentEncodedByteAt(input, i)) {
|
|
3032
|
+
return false;
|
|
3033
|
+
}
|
|
3034
|
+
i += 3;
|
|
3035
|
+
continue;
|
|
3036
|
+
}
|
|
3037
|
+
var codePoint = input.codePointAt(i);
|
|
3038
|
+
if (!isURLCodePoint(codePoint) || excludedCodePoints.has(codePoint)) {
|
|
3039
|
+
return false;
|
|
3040
|
+
}
|
|
3041
|
+
i += codePoint > 0xFFFF ? 2 : 1;
|
|
3042
|
+
}
|
|
3043
|
+
return true;
|
|
3044
|
+
}
|
|
3045
|
+
urlStringValidator = {
|
|
3046
|
+
isValidURLString: isValidURLString
|
|
3047
|
+
};
|
|
3048
|
+
return urlStringValidator;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
var hasRequiredWhatwgUrl;
|
|
3052
|
+
|
|
3053
|
+
function requireWhatwgUrl () {
|
|
3054
|
+
if (hasRequiredWhatwgUrl) return whatwgUrl;
|
|
3055
|
+
hasRequiredWhatwgUrl = 1;
|
|
3056
|
+
|
|
3057
|
+
var _require = requireWebidl2jsWrapper(),
|
|
3058
|
+
URL = _require.URL,
|
|
3059
|
+
URLSearchParams = _require.URLSearchParams;
|
|
3060
|
+
var urlStateMachine = require$$1$1;
|
|
3061
|
+
var percentEncoding = require$$2;
|
|
3062
|
+
var urlStringValidator = requireUrlStringValidator();
|
|
3063
|
+
var sharedGlobalObject = {
|
|
3064
|
+
Array: Array,
|
|
3065
|
+
Object: Object,
|
|
3066
|
+
Promise: Promise,
|
|
3067
|
+
String: String,
|
|
3068
|
+
TypeError: TypeError
|
|
3069
|
+
};
|
|
3070
|
+
URL.install(sharedGlobalObject, ["Window"]);
|
|
3071
|
+
URLSearchParams.install(sharedGlobalObject, ["Window"]);
|
|
3072
|
+
whatwgUrl.URL = sharedGlobalObject.URL;
|
|
3073
|
+
whatwgUrl.URLSearchParams = sharedGlobalObject.URLSearchParams;
|
|
3074
|
+
whatwgUrl.parseURL = urlStateMachine.parseURL;
|
|
3075
|
+
whatwgUrl.parseURLWithValidationErrors = urlStateMachine.parseURLWithValidationErrors;
|
|
3076
|
+
whatwgUrl.isValidURLString = urlStringValidator.isValidURLString;
|
|
3077
|
+
whatwgUrl.basicURLParse = urlStateMachine.basicURLParse;
|
|
3078
|
+
whatwgUrl.serializeURL = urlStateMachine.serializeURL;
|
|
3079
|
+
whatwgUrl.serializePath = urlStateMachine.serializePath;
|
|
3080
|
+
whatwgUrl.serializeHost = urlStateMachine.serializeHost;
|
|
3081
|
+
whatwgUrl.serializeInteger = urlStateMachine.serializeInteger;
|
|
3082
|
+
whatwgUrl.serializeURLOrigin = urlStateMachine.serializeURLOrigin;
|
|
3083
|
+
whatwgUrl.setTheUsername = urlStateMachine.setTheUsername;
|
|
3084
|
+
whatwgUrl.setThePassword = urlStateMachine.setThePassword;
|
|
3085
|
+
whatwgUrl.cannotHaveAUsernamePasswordPort = urlStateMachine.cannotHaveAUsernamePasswordPort;
|
|
3086
|
+
whatwgUrl.hasAnOpaquePath = urlStateMachine.hasAnOpaquePath;
|
|
3087
|
+
whatwgUrl.percentDecodeString = percentEncoding.percentDecodeString;
|
|
3088
|
+
whatwgUrl.percentDecodeBytes = percentEncoding.percentDecodeBytes;
|
|
3089
|
+
return whatwgUrl;
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
var whatwgUrlExports = requireWhatwgUrl();
|
|
3093
|
+
var whatwgURL = /*@__PURE__*/getDefaultExportFromCjs(whatwgUrlExports);
|
|
3094
|
+
|
|
3095
|
+
/**
|
|
3096
|
+
* @todo We could use `import generateUUID from 'uuid/v4';` (but it needs
|
|
3097
|
+
* crypto library, etc.; `rollup-plugin-node-builtins` doesn't recommend
|
|
3098
|
+
* using its own version and though there is <https://www.npmjs.com/package/crypto-browserify>,
|
|
3099
|
+
* it may be troublesome to bundle and not strongly needed)
|
|
3100
|
+
* @returns {string}
|
|
3101
|
+
*/
|
|
3102
|
+
function generateUUID() {
|
|
3103
|
+
// Adapted from original: public domain/MIT: https://stackoverflow.com/a/8809472/271577
|
|
3104
|
+
/* c8 ignore next */
|
|
3105
|
+
var d = Date.now();
|
|
3106
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/g, function (c) {
|
|
3107
|
+
/* eslint-disable no-bitwise, sonarjs/pseudo-random -- Convenient */
|
|
3108
|
+
var r = Math.trunc((d + Math.random() * 16) % 16);
|
|
3109
|
+
d = Math.floor(d / 16);
|
|
3110
|
+
return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
|
|
3111
|
+
/* eslint-enable no-bitwise, sonarjs/pseudo-random -- Convenient */
|
|
3112
|
+
});
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3115
|
+
/* eslint-disable unicorn/no-this-outside-of-class -- Monkey-patching */
|
|
3116
|
+
// @ts-nocheck -- jsdom has no types for the file we need
|
|
3117
|
+
/* globals location, XMLHttpRequest -- Polyfills */
|
|
3118
|
+
|
|
3119
|
+
var require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('createObjectURL.cjs', document.baseURI).href)));
|
|
3120
|
+
var _require = require$1('jsdom/lib/generated/idl/utils.js'),
|
|
3121
|
+
implForWrapper = _require.implForWrapper;
|
|
3122
|
+
var serializeURLOrigin = whatwgURL.serializeURLOrigin,
|
|
3123
|
+
parseURL = whatwgURL.parseURL;
|
|
3124
|
+
|
|
3125
|
+
/**
|
|
3126
|
+
* @type {{[key: string]: Blob}}
|
|
3127
|
+
*/
|
|
3128
|
+
var blobURLs = {};
|
|
3129
|
+
|
|
3130
|
+
/**
|
|
3131
|
+
* @param {Blob} blob
|
|
3132
|
+
* @returns {string}
|
|
3133
|
+
*/
|
|
3134
|
+
var createObjectURL = function createObjectURL(blob) {
|
|
3135
|
+
var parsedURL = parseURL(location.href);
|
|
3136
|
+
// https://github.com/jsdom/jsdom/issues/1721#issuecomment-282465529
|
|
3137
|
+
var blobURL = 'blob:' + (parsedURL ? serializeURLOrigin(parsedURL)
|
|
3138
|
+
// While `parseURL` can return `null`, `location.href`
|
|
3139
|
+
// tends not to allow
|
|
3140
|
+
/* c8 ignore next */ : 'null') + '/' + generateUUID();
|
|
3141
|
+
blobURLs[blobURL] = blob;
|
|
3142
|
+
return blobURL;
|
|
3143
|
+
};
|
|
3144
|
+
|
|
3145
|
+
/**
|
|
3146
|
+
* @param {string} blobURL
|
|
3147
|
+
* @returns {void}
|
|
3148
|
+
*/
|
|
3149
|
+
var revokeObjectURL = function revokeObjectURL(blobURL) {
|
|
3150
|
+
delete blobURLs[blobURL];
|
|
3151
|
+
};
|
|
3152
|
+
|
|
3153
|
+
// We only handle the case of binary, so no need to override `open`
|
|
3154
|
+
// in all cases; but this only works if override is called first
|
|
3155
|
+
|
|
3156
|
+
/**
|
|
3157
|
+
* @callback XMLHttpRequestMimeOverrider
|
|
3158
|
+
* @param {string} mimeType
|
|
3159
|
+
* @returns {void}
|
|
3160
|
+
*/
|
|
3161
|
+
|
|
3162
|
+
/**
|
|
3163
|
+
* @param {object} [cfg]
|
|
3164
|
+
* @param {boolean} [cfg.polyfillDataURLs]
|
|
3165
|
+
* @returns {XMLHttpRequestMimeOverrider}
|
|
3166
|
+
*/
|
|
3167
|
+
var xmlHttpRequestOverrideMimeType = function xmlHttpRequestOverrideMimeType() {
|
|
3168
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
3169
|
+
polyfillDataURLs = _ref.polyfillDataURLs;
|
|
3170
|
+
// Set these references late in case global `XMLHttpRequest` has since
|
|
3171
|
+
// been changed/set
|
|
3172
|
+
var _xhropen = XMLHttpRequest.prototype.open;
|
|
3173
|
+
var _xhrOverrideMimeType = XMLHttpRequest.prototype.overrideMimeType;
|
|
3174
|
+
return function (mimeType) {
|
|
3175
|
+
if (mimeType === 'text/plain; charset=x-user-defined') {
|
|
3176
|
+
/**
|
|
3177
|
+
* @param {string} method
|
|
3178
|
+
* @param {string} url
|
|
3179
|
+
* @param {boolean} async
|
|
3180
|
+
* @returns {void}
|
|
3181
|
+
*/
|
|
3182
|
+
this.open = function (method, url, async) {
|
|
3183
|
+
if (url.startsWith('blob:')) {
|
|
3184
|
+
var blob = blobURLs[url];
|
|
3185
|
+
if (!blob) {
|
|
3186
|
+
this.send = function () {
|
|
3187
|
+
throw new DOMException("Failed to execute 'send' on " + "'XMLHttpRequest': Failed to " + "load '".concat(url, "'"), 'NetworkError');
|
|
3188
|
+
};
|
|
3189
|
+
return undefined;
|
|
3190
|
+
}
|
|
3191
|
+
var responseType = 'text/plain'; // blob.type;
|
|
3192
|
+
// utf16le and base64 both convert lone surrogates
|
|
3193
|
+
var blobImpl = implForWrapper(blob);
|
|
3194
|
+
// jsdom changed Blob internals from `_buffer`
|
|
3195
|
+
// to `_bytes`; support both.
|
|
3196
|
+
var encoded = Buffer.from(blobImpl._bytes).toString('binary');
|
|
3197
|
+
|
|
3198
|
+
// Not usable in jsdom which makes properties readonly,
|
|
3199
|
+
// but local-xmlhttprequest can use (and jsdom can
|
|
3200
|
+
// handle data URLs anyways)
|
|
3201
|
+
if (polyfillDataURLs) {
|
|
3202
|
+
this.status = 200;
|
|
3203
|
+
this.send = function () {
|
|
3204
|
+
// Empty
|
|
3205
|
+
};
|
|
3206
|
+
this.responseType = responseType;
|
|
3207
|
+
this.responseText = encoded;
|
|
3208
|
+
return undefined;
|
|
3209
|
+
}
|
|
3210
|
+
url = 'data:' + responseType + ',' + encodeURIComponent(encoded);
|
|
3211
|
+
}
|
|
3212
|
+
return _xhropen.call(this, method, url, async);
|
|
3213
|
+
};
|
|
3214
|
+
|
|
3215
|
+
// As of jsdom 22.0.0, this is needed as the code below will
|
|
3216
|
+
// have its own effects in overriding `responseText`
|
|
3217
|
+
return undefined;
|
|
3218
|
+
}
|
|
3219
|
+
// The presence of `XMLHttpRequest.prototype.overrideMimeType`
|
|
3220
|
+
// is not really needed here, so making optional
|
|
3221
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
3222
|
+
args[_key - 1] = arguments[_key];
|
|
3223
|
+
}
|
|
3224
|
+
return _xhrOverrideMimeType && _xhrOverrideMimeType.call.apply(_xhrOverrideMimeType, [this, mimeType].concat(args));
|
|
3225
|
+
};
|
|
3226
|
+
};
|
|
3227
|
+
|
|
3228
|
+
exports.createObjectURL = createObjectURL;
|
|
3229
|
+
exports.revokeObjectURL = revokeObjectURL;
|
|
3230
|
+
exports.xmlHttpRequestOverrideMimeType = xmlHttpRequestOverrideMimeType;
|
|
3231
|
+
//# sourceMappingURL=createObjectURL.cjs.map
|