whatwg-url-without-unicode
Advanced tools
+24
| "use strict"; | ||
| const { URL, URLSearchParams } = require("./webidl2js-wrapper"); | ||
| const urlStateMachine = require("./lib/url-state-machine"); | ||
| const urlEncoded = require("./lib/urlencoded"); | ||
| const sharedGlobalObject = {}; | ||
| URL.install(sharedGlobalObject); | ||
| URLSearchParams.install(sharedGlobalObject); | ||
| exports.URL = sharedGlobalObject.URL; | ||
| exports.URLSearchParams = sharedGlobalObject.URLSearchParams; | ||
| exports.parseURL = urlStateMachine.parseURL; | ||
| exports.basicURLParse = urlStateMachine.basicURLParse; | ||
| exports.serializeURL = urlStateMachine.serializeURL; | ||
| exports.serializeHost = urlStateMachine.serializeHost; | ||
| exports.serializeInteger = urlStateMachine.serializeInteger; | ||
| exports.serializeURLOrigin = urlStateMachine.serializeURLOrigin; | ||
| exports.setTheUsername = urlStateMachine.setTheUsername; | ||
| exports.setThePassword = urlStateMachine.setThePassword; | ||
| exports.cannotHaveAUsernamePasswordPort = urlStateMachine.cannotHaveAUsernamePasswordPort; | ||
| exports.percentDecode = urlEncoded.percentDecode; |
| "use strict"; | ||
| const URL = require("./lib/URL"); | ||
| const URLSearchParams = require("./lib/URLSearchParams"); | ||
| exports.URL = URL; | ||
| exports.URLSearchParams = URLSearchParams; |
+2
-2
@@ -7,3 +7,3 @@ "use strict"; | ||
| exports.implementation = class URLImpl { | ||
| constructor(constructorArgs) { | ||
| constructor(globalObject, constructorArgs) { | ||
| const url = constructorArgs[0]; | ||
@@ -31,3 +31,3 @@ const base = constructorArgs[1]; | ||
| // question mark by default. Therefore the doNotStripQMark hack is used. | ||
| this._query = URLSearchParams.createImpl([query], { doNotStripQMark: true }); | ||
| this._query = URLSearchParams.createImpl(globalObject, [query], { doNotStripQMark: true }); | ||
| this._query._url = this; | ||
@@ -34,0 +34,0 @@ } |
@@ -1102,3 +1102,3 @@ "use strict"; | ||
| if (!isNaN(c)) { | ||
| this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode); | ||
| this.url.path[0] += percentEncodeChar(c, isC0ControlPercentEncode); | ||
| } | ||
@@ -1105,0 +1105,0 @@ } |
+280
-251
@@ -7,326 +7,355 @@ "use strict"; | ||
| const impl = utils.implSymbol; | ||
| const ctorRegistry = utils.ctorRegistrySymbol; | ||
| class URL { | ||
| constructor(url) { | ||
| if (arguments.length < 1) { | ||
| throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present."); | ||
| const iface = { | ||
| // When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()` | ||
| // method into this array. It allows objects that directly implements *those* interfaces to be recognized as | ||
| // implementing this mixin interface. | ||
| _mixedIntoPredicates: [], | ||
| is(obj) { | ||
| if (obj) { | ||
| if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) { | ||
| return true; | ||
| } | ||
| for (const isMixedInto of module.exports._mixedIntoPredicates) { | ||
| if (isMixedInto(obj)) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { context: "Failed to construct 'URL': parameter 1" }); | ||
| args.push(curArg); | ||
| } | ||
| { | ||
| let curArg = arguments[1]; | ||
| if (curArg !== undefined) { | ||
| curArg = conversions["USVString"](curArg, { context: "Failed to construct 'URL': parameter 2" }); | ||
| return false; | ||
| }, | ||
| isImpl(obj) { | ||
| if (obj) { | ||
| if (obj instanceof Impl.implementation) { | ||
| return true; | ||
| } | ||
| args.push(curArg); | ||
| const wrapper = utils.wrapperForImpl(obj); | ||
| for (const isMixedInto of module.exports._mixedIntoPredicates) { | ||
| if (isMixedInto(wrapper)) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return iface.setup(Object.create(new.target.prototype), args); | ||
| } | ||
| return false; | ||
| }, | ||
| convert(obj, { context = "The provided value" } = {}) { | ||
| if (module.exports.is(obj)) { | ||
| return utils.implForWrapper(obj); | ||
| } | ||
| throw new TypeError(`${context} is not of type 'URL'.`); | ||
| }, | ||
| toJSON() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| create(globalObject, constructorArgs, privateData) { | ||
| if (globalObject[ctorRegistry] === undefined) { | ||
| throw new Error("Internal error: invalid global object"); | ||
| } | ||
| return this[impl].toJSON(); | ||
| } | ||
| get href() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| const ctor = globalObject[ctorRegistry]["URL"]; | ||
| if (ctor === undefined) { | ||
| throw new Error("Internal error: constructor URL is not installed on the passed global object"); | ||
| } | ||
| return this[impl]["href"]; | ||
| } | ||
| let obj = Object.create(ctor.prototype); | ||
| obj = iface.setup(obj, globalObject, constructorArgs, privateData); | ||
| return obj; | ||
| }, | ||
| createImpl(globalObject, constructorArgs, privateData) { | ||
| const obj = iface.create(globalObject, constructorArgs, privateData); | ||
| return utils.implForWrapper(obj); | ||
| }, | ||
| _internalSetup(obj) {}, | ||
| setup(obj, globalObject, constructorArgs = [], privateData = {}) { | ||
| privateData.wrapper = obj; | ||
| set href(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| iface._internalSetup(obj); | ||
| Object.defineProperty(obj, impl, { | ||
| value: new Impl.implementation(globalObject, constructorArgs, privateData), | ||
| configurable: true | ||
| }); | ||
| obj[impl][utils.wrapperSymbol] = obj; | ||
| if (Impl.init) { | ||
| Impl.init(obj[impl], privateData); | ||
| } | ||
| return obj; | ||
| }, | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'href' property on 'URL': The provided value" }); | ||
| install(globalObject) { | ||
| class URL { | ||
| constructor(url) { | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { context: "Failed to construct 'URL': parameter 1" }); | ||
| args.push(curArg); | ||
| } | ||
| { | ||
| let curArg = arguments[1]; | ||
| if (curArg !== undefined) { | ||
| curArg = conversions["USVString"](curArg, { context: "Failed to construct 'URL': parameter 2" }); | ||
| } | ||
| args.push(curArg); | ||
| } | ||
| return iface.setup(Object.create(new.target.prototype), globalObject, args); | ||
| } | ||
| this[impl]["href"] = V; | ||
| } | ||
| toJSON() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| toString() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["href"]; | ||
| } | ||
| return this[impl].toJSON(); | ||
| } | ||
| get origin() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| get href() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["origin"]; | ||
| } | ||
| return this[impl]["href"]; | ||
| } | ||
| get protocol() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set href(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["protocol"]; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'href' property on 'URL': The provided value" }); | ||
| set protocol(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["href"] = V; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'protocol' property on 'URL': The provided value" }); | ||
| toString() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["href"]; | ||
| } | ||
| this[impl]["protocol"] = V; | ||
| } | ||
| get origin() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| get username() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["origin"]; | ||
| } | ||
| return this[impl]["username"]; | ||
| } | ||
| get protocol() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set username(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["protocol"]; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'username' property on 'URL': The provided value" }); | ||
| set protocol(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["username"] = V; | ||
| } | ||
| V = conversions["USVString"](V, { | ||
| context: "Failed to set the 'protocol' property on 'URL': The provided value" | ||
| }); | ||
| get password() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["protocol"] = V; | ||
| } | ||
| return this[impl]["password"]; | ||
| } | ||
| get username() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set password(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["username"]; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'password' property on 'URL': The provided value" }); | ||
| set username(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["password"] = V; | ||
| } | ||
| V = conversions["USVString"](V, { | ||
| context: "Failed to set the 'username' property on 'URL': The provided value" | ||
| }); | ||
| get host() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["username"] = V; | ||
| } | ||
| return this[impl]["host"]; | ||
| } | ||
| get password() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set host(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["password"]; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'host' property on 'URL': The provided value" }); | ||
| set password(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["host"] = V; | ||
| } | ||
| V = conversions["USVString"](V, { | ||
| context: "Failed to set the 'password' property on 'URL': The provided value" | ||
| }); | ||
| get hostname() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["password"] = V; | ||
| } | ||
| return this[impl]["hostname"]; | ||
| } | ||
| get host() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set hostname(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["host"]; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'hostname' property on 'URL': The provided value" }); | ||
| set host(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["hostname"] = V; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'host' property on 'URL': The provided value" }); | ||
| get port() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["host"] = V; | ||
| } | ||
| return this[impl]["port"]; | ||
| } | ||
| get hostname() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set port(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["hostname"]; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'port' property on 'URL': The provided value" }); | ||
| set hostname(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["port"] = V; | ||
| } | ||
| V = conversions["USVString"](V, { | ||
| context: "Failed to set the 'hostname' property on 'URL': The provided value" | ||
| }); | ||
| get pathname() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["hostname"] = V; | ||
| } | ||
| return this[impl]["pathname"]; | ||
| } | ||
| get port() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set pathname(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["port"]; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'pathname' property on 'URL': The provided value" }); | ||
| set port(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["pathname"] = V; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'port' property on 'URL': The provided value" }); | ||
| get search() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["port"] = V; | ||
| } | ||
| return this[impl]["search"]; | ||
| } | ||
| get pathname() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set search(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["pathname"]; | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'search' property on 'URL': The provided value" }); | ||
| set pathname(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["search"] = V; | ||
| } | ||
| V = conversions["USVString"](V, { | ||
| context: "Failed to set the 'pathname' property on 'URL': The provided value" | ||
| }); | ||
| get searchParams() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| this[impl]["pathname"] = V; | ||
| } | ||
| return utils.getSameObject(this, "searchParams", () => { | ||
| return utils.tryWrapperForImpl(this[impl]["searchParams"]); | ||
| }); | ||
| } | ||
| get search() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| get hash() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["search"]; | ||
| } | ||
| return this[impl]["hash"]; | ||
| } | ||
| set search(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| set hash(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| V = conversions["USVString"](V, { | ||
| context: "Failed to set the 'search' property on 'URL': The provided value" | ||
| }); | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'hash' property on 'URL': The provided value" }); | ||
| this[impl]["search"] = V; | ||
| } | ||
| this[impl]["hash"] = V; | ||
| } | ||
| } | ||
| Object.defineProperties(URL.prototype, { | ||
| toJSON: { enumerable: true }, | ||
| href: { enumerable: true }, | ||
| toString: { enumerable: true }, | ||
| origin: { enumerable: true }, | ||
| protocol: { enumerable: true }, | ||
| username: { enumerable: true }, | ||
| password: { enumerable: true }, | ||
| host: { enumerable: true }, | ||
| hostname: { enumerable: true }, | ||
| port: { enumerable: true }, | ||
| pathname: { enumerable: true }, | ||
| search: { enumerable: true }, | ||
| searchParams: { enumerable: true }, | ||
| hash: { enumerable: true }, | ||
| [Symbol.toStringTag]: { value: "URL", configurable: true } | ||
| }); | ||
| const iface = { | ||
| // When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()` | ||
| // method into this array. It allows objects that directly implements *those* interfaces to be recognized as | ||
| // implementing this mixin interface. | ||
| _mixedIntoPredicates: [], | ||
| is(obj) { | ||
| if (obj) { | ||
| if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) { | ||
| return true; | ||
| get searchParams() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return utils.getSameObject(this, "searchParams", () => { | ||
| return utils.tryWrapperForImpl(this[impl]["searchParams"]); | ||
| }); | ||
| } | ||
| for (const isMixedInto of module.exports._mixedIntoPredicates) { | ||
| if (isMixedInto(obj)) { | ||
| return true; | ||
| get hash() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl]["hash"]; | ||
| } | ||
| } | ||
| return false; | ||
| }, | ||
| isImpl(obj) { | ||
| if (obj) { | ||
| if (obj instanceof Impl.implementation) { | ||
| return true; | ||
| } | ||
| const wrapper = utils.wrapperForImpl(obj); | ||
| for (const isMixedInto of module.exports._mixedIntoPredicates) { | ||
| if (isMixedInto(wrapper)) { | ||
| return true; | ||
| set hash(V) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| V = conversions["USVString"](V, { context: "Failed to set the 'hash' property on 'URL': The provided value" }); | ||
| this[impl]["hash"] = V; | ||
| } | ||
| } | ||
| return false; | ||
| }, | ||
| convert(obj, { context = "The provided value" } = {}) { | ||
| if (module.exports.is(obj)) { | ||
| return utils.implForWrapper(obj); | ||
| Object.defineProperties(URL.prototype, { | ||
| toJSON: { enumerable: true }, | ||
| href: { enumerable: true }, | ||
| toString: { enumerable: true }, | ||
| origin: { enumerable: true }, | ||
| protocol: { enumerable: true }, | ||
| username: { enumerable: true }, | ||
| password: { enumerable: true }, | ||
| host: { enumerable: true }, | ||
| hostname: { enumerable: true }, | ||
| port: { enumerable: true }, | ||
| pathname: { enumerable: true }, | ||
| search: { enumerable: true }, | ||
| searchParams: { enumerable: true }, | ||
| hash: { enumerable: true }, | ||
| [Symbol.toStringTag]: { value: "URL", configurable: true } | ||
| }); | ||
| if (globalObject[ctorRegistry] === undefined) { | ||
| globalObject[ctorRegistry] = Object.create(null); | ||
| } | ||
| throw new TypeError(`${context} is not of type 'URL'.`); | ||
| }, | ||
| globalObject[ctorRegistry]["URL"] = URL; | ||
| create(constructorArgs, privateData) { | ||
| let obj = Object.create(URL.prototype); | ||
| obj = this.setup(obj, constructorArgs, privateData); | ||
| return obj; | ||
| }, | ||
| createImpl(constructorArgs, privateData) { | ||
| let obj = Object.create(URL.prototype); | ||
| obj = this.setup(obj, constructorArgs, privateData); | ||
| return utils.implForWrapper(obj); | ||
| }, | ||
| _internalSetup(obj) {}, | ||
| setup(obj, constructorArgs, privateData) { | ||
| if (!privateData) privateData = {}; | ||
| privateData.wrapper = obj; | ||
| this._internalSetup(obj); | ||
| Object.defineProperty(obj, impl, { | ||
| value: new Impl.implementation(constructorArgs, privateData), | ||
| configurable: true | ||
| Object.defineProperty(globalObject, "URL", { | ||
| configurable: true, | ||
| writable: true, | ||
| value: URL | ||
| }); | ||
| obj[impl][utils.wrapperSymbol] = obj; | ||
| if (Impl.init) { | ||
| Impl.init(obj[impl], privateData); | ||
| } | ||
| return obj; | ||
| }, | ||
| interface: URL, | ||
| expose: { | ||
| Window: { URL }, | ||
| Worker: { URL } | ||
| } | ||
@@ -333,0 +362,0 @@ }; // iface |
| "use strict"; | ||
| const stableSortBy = require("lodash.sortby"); | ||
| const urlencoded = require("./urlencoded"); | ||
| function stableSortBy(arr, compare) { | ||
| return arr | ||
| .map((item, index) => ({ item, index })) | ||
| .sort((a, b) => compare(a.item, b.item) || a.index - b.index) | ||
| .map(({ item }) => item); | ||
| } | ||
| exports.implementation = class URLSearchParamsImpl { | ||
| constructor(constructorArgs, { doNotStripQMark = false }) { | ||
| constructor(globalObject, constructorArgs, { doNotStripQMark = false }) { | ||
| let init = constructorArgs[0]; | ||
@@ -111,3 +117,3 @@ this._list = []; | ||
| sort() { | ||
| this._list = stableSortBy(this._list, [0]); | ||
| this._list = stableSortBy(this._list, (a, b) => a[0] > b[0]); | ||
| this._updateSteps(); | ||
@@ -114,0 +120,0 @@ } |
+345
-316
@@ -7,2 +7,3 @@ "use strict"; | ||
| const impl = utils.implSymbol; | ||
| const ctorRegistry = utils.ctorRegistrySymbol; | ||
@@ -47,304 +48,3 @@ const IteratorPrototype = Object.create(utils.IteratorPrototype, { | ||
| }); | ||
| class URLSearchParams { | ||
| constructor() { | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| if (curArg !== undefined) { | ||
| if (utils.isObject(curArg)) { | ||
| if (curArg[Symbol.iterator] !== undefined) { | ||
| if (!utils.isObject(curArg)) { | ||
| throw new TypeError( | ||
| "Failed to construct 'URLSearchParams': parameter 1" + " sequence" + " is not an iterable object." | ||
| ); | ||
| } else { | ||
| const V = []; | ||
| const tmp = curArg; | ||
| for (let nextItem of tmp) { | ||
| if (!utils.isObject(nextItem)) { | ||
| throw new TypeError( | ||
| "Failed to construct 'URLSearchParams': parameter 1" + | ||
| " sequence" + | ||
| "'s element" + | ||
| " is not an iterable object." | ||
| ); | ||
| } else { | ||
| const V = []; | ||
| const tmp = nextItem; | ||
| for (let nextItem of tmp) { | ||
| nextItem = conversions["USVString"](nextItem, { | ||
| context: | ||
| "Failed to construct 'URLSearchParams': parameter 1" + " sequence" + "'s element" + "'s element" | ||
| }); | ||
| V.push(nextItem); | ||
| } | ||
| nextItem = V; | ||
| } | ||
| V.push(nextItem); | ||
| } | ||
| curArg = V; | ||
| } | ||
| } else { | ||
| if (!utils.isObject(curArg)) { | ||
| throw new TypeError( | ||
| "Failed to construct 'URLSearchParams': parameter 1" + " record" + " is not an object." | ||
| ); | ||
| } else { | ||
| const result = Object.create(null); | ||
| for (const key of Reflect.ownKeys(curArg)) { | ||
| const desc = Object.getOwnPropertyDescriptor(curArg, key); | ||
| if (desc && desc.enumerable) { | ||
| let typedKey = key; | ||
| typedKey = conversions["USVString"](typedKey, { | ||
| context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s key" | ||
| }); | ||
| let typedValue = curArg[key]; | ||
| typedValue = conversions["USVString"](typedValue, { | ||
| context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s value" | ||
| }); | ||
| result[typedKey] = typedValue; | ||
| } | ||
| } | ||
| curArg = result; | ||
| } | ||
| } | ||
| } else { | ||
| curArg = conversions["USVString"](curArg, { context: "Failed to construct 'URLSearchParams': parameter 1" }); | ||
| } | ||
| } else { | ||
| curArg = ""; | ||
| } | ||
| args.push(curArg); | ||
| } | ||
| return iface.setup(Object.create(new.target.prototype), args); | ||
| } | ||
| append(name, value) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 2) { | ||
| throw new TypeError( | ||
| "Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'append' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| { | ||
| let curArg = arguments[1]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'append' on 'URLSearchParams': parameter 2" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].append(...args); | ||
| } | ||
| delete(name) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].delete(...args); | ||
| } | ||
| get(name) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only " + arguments.length + " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'get' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].get(...args); | ||
| } | ||
| getAll(name) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return utils.tryWrapperForImpl(this[impl].getAll(...args)); | ||
| } | ||
| has(name) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only " + arguments.length + " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'has' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].has(...args); | ||
| } | ||
| set(name, value) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 2) { | ||
| throw new TypeError( | ||
| "Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only " + arguments.length + " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'set' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| { | ||
| let curArg = arguments[1]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'set' on 'URLSearchParams': parameter 2" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].set(...args); | ||
| } | ||
| sort() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl].sort(); | ||
| } | ||
| toString() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl].toString(); | ||
| } | ||
| keys() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return module.exports.createDefaultIterator(this, "key"); | ||
| } | ||
| values() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return module.exports.createDefaultIterator(this, "value"); | ||
| } | ||
| entries() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return module.exports.createDefaultIterator(this, "key+value"); | ||
| } | ||
| forEach(callback) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError("Failed to execute 'forEach' on 'iterable': 1 argument required, " + "but only 0 present."); | ||
| } | ||
| if (typeof callback !== "function") { | ||
| throw new TypeError( | ||
| "Failed to execute 'forEach' on 'iterable': The callback provided " + "as parameter 1 is not a function." | ||
| ); | ||
| } | ||
| const thisArg = arguments[1]; | ||
| let pairs = Array.from(this[impl]); | ||
| let i = 0; | ||
| while (i < pairs.length) { | ||
| const [key, value] = pairs[i].map(utils.tryWrapperForImpl); | ||
| callback.call(thisArg, value, key, this); | ||
| pairs = Array.from(this[impl]); | ||
| i++; | ||
| } | ||
| } | ||
| } | ||
| Object.defineProperties(URLSearchParams.prototype, { | ||
| append: { enumerable: true }, | ||
| delete: { enumerable: true }, | ||
| get: { enumerable: true }, | ||
| getAll: { enumerable: true }, | ||
| has: { enumerable: true }, | ||
| set: { enumerable: true }, | ||
| sort: { enumerable: true }, | ||
| toString: { enumerable: true }, | ||
| keys: { enumerable: true }, | ||
| values: { enumerable: true }, | ||
| entries: { enumerable: true }, | ||
| forEach: { enumerable: true }, | ||
| [Symbol.toStringTag]: { value: "URLSearchParams", configurable: true }, | ||
| [Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true } | ||
| }); | ||
| const iface = { | ||
@@ -399,21 +99,27 @@ // When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()` | ||
| create(constructorArgs, privateData) { | ||
| let obj = Object.create(URLSearchParams.prototype); | ||
| obj = this.setup(obj, constructorArgs, privateData); | ||
| create(globalObject, constructorArgs, privateData) { | ||
| if (globalObject[ctorRegistry] === undefined) { | ||
| throw new Error("Internal error: invalid global object"); | ||
| } | ||
| const ctor = globalObject[ctorRegistry]["URLSearchParams"]; | ||
| if (ctor === undefined) { | ||
| throw new Error("Internal error: constructor URLSearchParams is not installed on the passed global object"); | ||
| } | ||
| let obj = Object.create(ctor.prototype); | ||
| obj = iface.setup(obj, globalObject, constructorArgs, privateData); | ||
| return obj; | ||
| }, | ||
| createImpl(constructorArgs, privateData) { | ||
| let obj = Object.create(URLSearchParams.prototype); | ||
| obj = this.setup(obj, constructorArgs, privateData); | ||
| createImpl(globalObject, constructorArgs, privateData) { | ||
| const obj = iface.create(globalObject, constructorArgs, privateData); | ||
| return utils.implForWrapper(obj); | ||
| }, | ||
| _internalSetup(obj) {}, | ||
| setup(obj, constructorArgs, privateData) { | ||
| if (!privateData) privateData = {}; | ||
| setup(obj, globalObject, constructorArgs = [], privateData = {}) { | ||
| privateData.wrapper = obj; | ||
| this._internalSetup(obj); | ||
| iface._internalSetup(obj); | ||
| Object.defineProperty(obj, impl, { | ||
| value: new Impl.implementation(constructorArgs, privateData), | ||
| value: new Impl.implementation(globalObject, constructorArgs, privateData), | ||
| configurable: true | ||
@@ -428,6 +134,329 @@ }); | ||
| }, | ||
| interface: URLSearchParams, | ||
| expose: { | ||
| Window: { URLSearchParams }, | ||
| Worker: { URLSearchParams } | ||
| install(globalObject) { | ||
| class URLSearchParams { | ||
| constructor() { | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| if (curArg !== undefined) { | ||
| if (utils.isObject(curArg)) { | ||
| if (curArg[Symbol.iterator] !== undefined) { | ||
| if (!utils.isObject(curArg)) { | ||
| throw new TypeError( | ||
| "Failed to construct 'URLSearchParams': parameter 1" + " sequence" + " is not an iterable object." | ||
| ); | ||
| } else { | ||
| const V = []; | ||
| const tmp = curArg; | ||
| for (let nextItem of tmp) { | ||
| if (!utils.isObject(nextItem)) { | ||
| throw new TypeError( | ||
| "Failed to construct 'URLSearchParams': parameter 1" + | ||
| " sequence" + | ||
| "'s element" + | ||
| " is not an iterable object." | ||
| ); | ||
| } else { | ||
| const V = []; | ||
| const tmp = nextItem; | ||
| for (let nextItem of tmp) { | ||
| nextItem = conversions["USVString"](nextItem, { | ||
| context: | ||
| "Failed to construct 'URLSearchParams': parameter 1" + | ||
| " sequence" + | ||
| "'s element" + | ||
| "'s element" | ||
| }); | ||
| V.push(nextItem); | ||
| } | ||
| nextItem = V; | ||
| } | ||
| V.push(nextItem); | ||
| } | ||
| curArg = V; | ||
| } | ||
| } else { | ||
| if (!utils.isObject(curArg)) { | ||
| throw new TypeError( | ||
| "Failed to construct 'URLSearchParams': parameter 1" + " record" + " is not an object." | ||
| ); | ||
| } else { | ||
| const result = Object.create(null); | ||
| for (const key of Reflect.ownKeys(curArg)) { | ||
| const desc = Object.getOwnPropertyDescriptor(curArg, key); | ||
| if (desc && desc.enumerable) { | ||
| let typedKey = key; | ||
| typedKey = conversions["USVString"](typedKey, { | ||
| context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s key" | ||
| }); | ||
| let typedValue = curArg[key]; | ||
| typedValue = conversions["USVString"](typedValue, { | ||
| context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s value" | ||
| }); | ||
| result[typedKey] = typedValue; | ||
| } | ||
| } | ||
| curArg = result; | ||
| } | ||
| } | ||
| } else { | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to construct 'URLSearchParams': parameter 1" | ||
| }); | ||
| } | ||
| } else { | ||
| curArg = ""; | ||
| } | ||
| args.push(curArg); | ||
| } | ||
| return iface.setup(Object.create(new.target.prototype), globalObject, args); | ||
| } | ||
| append(name, value) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 2) { | ||
| throw new TypeError( | ||
| "Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'append' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| { | ||
| let curArg = arguments[1]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'append' on 'URLSearchParams': parameter 2" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].append(...args); | ||
| } | ||
| delete(name) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].delete(...args); | ||
| } | ||
| get(name) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'get' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].get(...args); | ||
| } | ||
| getAll(name) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return utils.tryWrapperForImpl(this[impl].getAll(...args)); | ||
| } | ||
| has(name) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'has' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].has(...args); | ||
| } | ||
| set(name, value) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 2) { | ||
| throw new TypeError( | ||
| "Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only " + | ||
| arguments.length + | ||
| " present." | ||
| ); | ||
| } | ||
| const args = []; | ||
| { | ||
| let curArg = arguments[0]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'set' on 'URLSearchParams': parameter 1" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| { | ||
| let curArg = arguments[1]; | ||
| curArg = conversions["USVString"](curArg, { | ||
| context: "Failed to execute 'set' on 'URLSearchParams': parameter 2" | ||
| }); | ||
| args.push(curArg); | ||
| } | ||
| return this[impl].set(...args); | ||
| } | ||
| sort() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl].sort(); | ||
| } | ||
| toString() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return this[impl].toString(); | ||
| } | ||
| keys() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return module.exports.createDefaultIterator(this, "key"); | ||
| } | ||
| values() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return module.exports.createDefaultIterator(this, "value"); | ||
| } | ||
| entries() { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| return module.exports.createDefaultIterator(this, "key+value"); | ||
| } | ||
| forEach(callback) { | ||
| if (!this || !module.exports.is(this)) { | ||
| throw new TypeError("Illegal invocation"); | ||
| } | ||
| if (arguments.length < 1) { | ||
| throw new TypeError( | ||
| "Failed to execute 'forEach' on 'iterable': 1 argument required, " + "but only 0 present." | ||
| ); | ||
| } | ||
| if (typeof callback !== "function") { | ||
| throw new TypeError( | ||
| "Failed to execute 'forEach' on 'iterable': The callback provided " + "as parameter 1 is not a function." | ||
| ); | ||
| } | ||
| const thisArg = arguments[1]; | ||
| let pairs = Array.from(this[impl]); | ||
| let i = 0; | ||
| while (i < pairs.length) { | ||
| const [key, value] = pairs[i].map(utils.tryWrapperForImpl); | ||
| callback.call(thisArg, value, key, this); | ||
| pairs = Array.from(this[impl]); | ||
| i++; | ||
| } | ||
| } | ||
| } | ||
| Object.defineProperties(URLSearchParams.prototype, { | ||
| append: { enumerable: true }, | ||
| delete: { enumerable: true }, | ||
| get: { enumerable: true }, | ||
| getAll: { enumerable: true }, | ||
| has: { enumerable: true }, | ||
| set: { enumerable: true }, | ||
| sort: { enumerable: true }, | ||
| toString: { enumerable: true }, | ||
| keys: { enumerable: true }, | ||
| values: { enumerable: true }, | ||
| entries: { enumerable: true }, | ||
| forEach: { enumerable: true }, | ||
| [Symbol.toStringTag]: { value: "URLSearchParams", configurable: true }, | ||
| [Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true } | ||
| }); | ||
| if (globalObject[ctorRegistry] === undefined) { | ||
| globalObject[ctorRegistry] = Object.create(null); | ||
| } | ||
| globalObject[ctorRegistry]["URLSearchParams"] = URLSearchParams; | ||
| Object.defineProperty(globalObject, "URLSearchParams", { | ||
| configurable: true, | ||
| writable: true, | ||
| value: URLSearchParams | ||
| }); | ||
| } | ||
@@ -434,0 +463,0 @@ }; // iface |
+14
-26
@@ -12,30 +12,6 @@ "use strict"; | ||
| const getOwnPropertyDescriptors = typeof Object.getOwnPropertyDescriptors === "function" ? | ||
| Object.getOwnPropertyDescriptors : | ||
| // Polyfill exists until we require Node.js v8.x | ||
| // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors | ||
| obj => { | ||
| if (obj === undefined || obj === null) { | ||
| throw new TypeError("Cannot convert undefined or null to object"); | ||
| } | ||
| obj = Object(obj); | ||
| const ownKeys = Reflect.ownKeys(obj); | ||
| const descriptors = {}; | ||
| for (const key of ownKeys) { | ||
| const descriptor = Reflect.getOwnPropertyDescriptor(obj, key); | ||
| if (descriptor !== undefined) { | ||
| Reflect.defineProperty(descriptors, key, { | ||
| value: descriptor, | ||
| writable: true, | ||
| enumerable: true, | ||
| configurable: true | ||
| }); | ||
| } | ||
| } | ||
| return descriptors; | ||
| }; | ||
| const wrapperSymbol = Symbol("wrapper"); | ||
| const implSymbol = Symbol("impl"); | ||
| const sameObjectCaches = Symbol("SameObject caches"); | ||
| const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry"); | ||
@@ -91,2 +67,13 @@ function getSameObject(wrapper, prop, creator) { | ||
| const byteLengthGetter = | ||
| Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get; | ||
| function isArrayBuffer(value) { | ||
| try { | ||
| byteLengthGetter.call(value); | ||
| return true; | ||
| } catch (e) { | ||
| return false; | ||
| } | ||
| } | ||
| const supportsPropertyIndex = Symbol("supports property index"); | ||
@@ -107,6 +94,6 @@ const supportedPropertyIndices = Symbol("supported property indices"); | ||
| hasOwn, | ||
| getOwnPropertyDescriptors, | ||
| wrapperSymbol, | ||
| implSymbol, | ||
| getSameObject, | ||
| ctorRegistrySymbol, | ||
| wrapperForImpl, | ||
@@ -118,2 +105,3 @@ implForWrapper, | ||
| IteratorPrototype, | ||
| isArrayBuffer, | ||
| isArrayIndexPropName, | ||
@@ -120,0 +108,0 @@ supportsPropertyIndex, |
+17
-13
| { | ||
| "name": "whatwg-url-without-unicode", | ||
| "version": "7.1.0", | ||
| "version": "8.0.0-0", | ||
| "description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery, without unicode support", | ||
| "main": "lib/public-api.js", | ||
| "main": "index.js", | ||
| "files": [ | ||
| "index.js", | ||
| "webidl2js-wrapper.js", | ||
| "lib/" | ||
@@ -13,14 +15,16 @@ ], | ||
| "dependencies": { | ||
| "lodash.sortby": "^4.7.0", | ||
| "webidl-conversions": "^4.0.2" | ||
| "webidl-conversions": "^5.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "browserify": "^16.2.2", | ||
| "domexception": "^1.0.1", | ||
| "eslint": "^5.4.0", | ||
| "got": "^9.2.2", | ||
| "jest": "^23.5.0", | ||
| "recast": "^0.15.3", | ||
| "webidl2js": "^9.0.1" | ||
| "browserify": "^16.5.0", | ||
| "domexception": "^2.0.1", | ||
| "eslint": "^6.8.0", | ||
| "got": "^10.2.1", | ||
| "jest": "^24.9.0", | ||
| "recast": "^0.18.5", | ||
| "webidl2js": "^12.0.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=10" | ||
| }, | ||
| "scripts": { | ||
@@ -30,5 +34,5 @@ "build": "node scripts/transform.js && node scripts/convert-idl.js", | ||
| "lint": "eslint .", | ||
| "prepublish": "node scripts/transform.js && node scripts/convert-idl.js", | ||
| "prepare": "node scripts/transform.js && node scripts/convert-idl.js", | ||
| "pretest": "node scripts/get-latest-platform-tests.js && node scripts/transform.js && node scripts/convert-idl.js", | ||
| "build-live-viewer": "browserify lib/public-api.js --standalone whatwgURL > live-viewer/whatwg-url.js", | ||
| "build-live-viewer": "browserify index.js --standalone whatwgURL > live-viewer/whatwg-url.js", | ||
| "test": "jest" | ||
@@ -35,0 +39,0 @@ }, |
+5
-1
@@ -74,2 +74,6 @@ # whatwg-url-without-unicode | ||
| ### `whatwg-url/webidl2js-wrapper` module | ||
| This module exports the `URL` and `URLSearchParams` [interface wrappers API](https://github.com/jsdom/webidl2js#for-interfaces) generated by [webidl2js](https://github.com/jsdom/webidl2js). | ||
| ## Development instructions | ||
@@ -79,3 +83,3 @@ | ||
| npm install | ||
| npm | ||
@@ -82,0 +86,0 @@ To run tests: |
| "use strict"; | ||
| exports.URL = require("./URL").interface; | ||
| exports.URLSearchParams = require("./URLSearchParams").interface; | ||
| exports.parseURL = require("./url-state-machine").parseURL; | ||
| exports.basicURLParse = require("./url-state-machine").basicURLParse; | ||
| exports.serializeURL = require("./url-state-machine").serializeURL; | ||
| exports.serializeHost = require("./url-state-machine").serializeHost; | ||
| exports.serializeInteger = require("./url-state-machine").serializeInteger; | ||
| exports.serializeURLOrigin = require("./url-state-machine").serializeURLOrigin; | ||
| exports.setTheUsername = require("./url-state-machine").setTheUsername; | ||
| exports.setThePassword = require("./url-state-machine").setThePassword; | ||
| exports.cannotHaveAUsernamePasswordPort = require("./url-state-machine").cannotHaveAUsernamePasswordPort; | ||
| exports.percentDecode = require("./urlencoded").percentDecode; |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
82049
4.77%1
-50%13
8.33%2360
2.39%105
3.96%2
-33.33%2
100%+ Added
- Removed
- Removed
- Removed
Updated