Socket
Socket
Sign inDemoInstall

whatwg-url

Package Overview
Dependencies
4
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.4.0 to 6.4.1

6

lib/URL-impl.js

@@ -45,2 +45,8 @@ "use strict";

this._url = parsedURL;
this._query._list.splice(0);
const { query } = parsedURL;
if (query !== null) {
this._query._list = urlencoded.parseUrlencoded(query);
}
}

@@ -47,0 +53,0 @@

11

lib/url-state-machine.js

@@ -127,3 +127,10 @@ "use strict";

const regex = R === 10 ? /[^0-9]/ : (R === 16 ? /[^0-9A-Fa-f]/ : /[^0-7]/);
let regex = /[^0-7]/;
if (R === 10) {
regex = /[^0-9]/;
}
if (R === 16) {
regex = /[^0-9A-Fa-f]/;
}
if (regex.test(input)) {

@@ -470,3 +477,3 @@ return failure;

function shortenPath(url) {
const path = url.path;
const { path } = url;
if (path.length === 0) {

@@ -473,0 +480,0 @@ return;

@@ -5,2 +5,3 @@ "use strict";

const utils = require("./utils.js");
const impl = utils.implSymbol;

@@ -11,7 +12,9 @@

throw new TypeError(
"Failed to construct 'URL'. Please use the 'new' operator; this constructor cannot be called as a function."
"Failed to construct 'URL'. Please use the 'new' operator; this constructor " + "cannot be called as a function."
);
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present.");
throw new TypeError(
"Failed to construct 'URL': 1 " + "argument required, but only " + arguments.length + " present."
);
}

@@ -23,3 +26,5 @@

}
args[0] = conversions["USVString"](args[0], { context: "Failed to construct 'URL': parameter 1" });
if (args[1] !== undefined) {

@@ -32,2 +37,9 @@ args[1] = conversions["USVString"](args[1], { context: "Failed to construct 'URL': parameter 2" });

Object.defineProperty(URL, "prototype", {
value: URL.prototype,
writable: false,
enumerable: false,
configurable: false
});
URL.prototype.toJSON = function toJSON() {

@@ -37,12 +49,25 @@ if (!this || !module.exports.is(this)) {

}
return this[impl].toJSON();
};
Object.defineProperty(URL.prototype, "href", {
get() {
return this[impl].href;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["href"];
},
set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
V = conversions["USVString"](V, { context: "Failed to set the 'href' property on 'URL': The provided value" });
this[impl].href = V;
this[impl]["href"] = V;
},
enumerable: true,

@@ -56,3 +81,3 @@ configurable: true

}
return this[impl].href;
return this[impl]["href"];
};

@@ -62,4 +87,9 @@

get() {
return this[impl].origin;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["origin"];
},
enumerable: true,

@@ -71,8 +101,19 @@ configurable: true

get() {
return this[impl].protocol;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["protocol"];
},
set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
V = conversions["USVString"](V, { context: "Failed to set the 'protocol' property on 'URL': The provided value" });
this[impl].protocol = V;
this[impl]["protocol"] = V;
},
enumerable: true,

@@ -84,8 +125,19 @@ configurable: true

get() {
return this[impl].username;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["username"];
},
set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
V = conversions["USVString"](V, { context: "Failed to set the 'username' property on 'URL': The provided value" });
this[impl].username = V;
this[impl]["username"] = V;
},
enumerable: true,

@@ -97,8 +149,19 @@ configurable: true

get() {
return this[impl].password;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["password"];
},
set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
V = conversions["USVString"](V, { context: "Failed to set the 'password' property on 'URL': The provided value" });
this[impl].password = V;
this[impl]["password"] = V;
},
enumerable: true,

@@ -110,8 +173,19 @@ configurable: true

get() {
return this[impl].host;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["host"];
},
set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
V = conversions["USVString"](V, { context: "Failed to set the 'host' property on 'URL': The provided value" });
this[impl].host = V;
this[impl]["host"] = V;
},
enumerable: true,

@@ -123,8 +197,19 @@ configurable: true

get() {
return this[impl].hostname;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["hostname"];
},
set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
V = conversions["USVString"](V, { context: "Failed to set the 'hostname' property on 'URL': The provided value" });
this[impl].hostname = V;
this[impl]["hostname"] = V;
},
enumerable: true,

@@ -136,8 +221,19 @@ configurable: true

get() {
return this[impl].port;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["port"];
},
set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
V = conversions["USVString"](V, { context: "Failed to set the 'port' property on 'URL': The provided value" });
this[impl].port = V;
this[impl]["port"] = V;
},
enumerable: true,

@@ -149,8 +245,19 @@ configurable: true

get() {
return this[impl].pathname;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["pathname"];
},
set(V) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
V = conversions["USVString"](V, { context: "Failed to set the 'pathname' property on 'URL': The provided value" });
this[impl].pathname = V;
this[impl]["pathname"] = V;
},
enumerable: true,

@@ -162,8 +269,19 @@ configurable: true

get() {
return this[impl].search;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["search"];
},
set(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" });
this[impl].search = V;
this[impl]["search"] = V;
},
enumerable: true,

@@ -175,6 +293,11 @@ configurable: true

get() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return utils.getSameObject(this, "searchParams", () => {
return utils.tryWrapperForImpl(this[impl].searchParams);
return utils.tryWrapperForImpl(this[impl]["searchParams"]);
});
},
enumerable: true,

@@ -186,8 +309,19 @@ configurable: true

get() {
return this[impl].hash;
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl]["hash"];
},
set(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;
this[impl]["hash"] = V;
},
enumerable: true,

@@ -240,5 +374,6 @@ configurable: true

},
create(constructorArgs, privateData) {
let obj = Object.create(URL.prototype);
this.setup(obj, constructorArgs, privateData);
obj = this.setup(obj, constructorArgs, privateData);
return obj;

@@ -248,3 +383,3 @@ },

let obj = Object.create(URL.prototype);
this.setup(obj, constructorArgs, privateData);
obj = this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);

@@ -255,6 +390,6 @@ },

if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
Object.defineProperty(obj, impl, {

@@ -266,12 +401,17 @@ value: new Impl.implementation(constructorArgs, privateData),

});
obj[impl][utils.wrapperSymbol] = obj;
if (Impl.init) {
Impl.init(obj[impl], privateData);
}
return obj;
},
interface: URL,
expose: {
Window: { URL: URL },
Worker: { URL: URL }
Window: { URL },
Worker: { URL }
}
};
}; // iface
module.exports = iface;
const Impl = require(".//URL-impl.js");

6

lib/urlencoded.js

@@ -87,6 +87,6 @@ "use strict";

byte === 46 ||
byte >= 48 && byte <= 57 ||
byte >= 65 && byte <= 90 ||
(byte >= 48 && byte <= 57) ||
(byte >= 65 && byte <= 90) ||
byte === 95 ||
byte >= 97 && byte <= 122) {
(byte >= 97 && byte <= 122)) {
output += String.fromCodePoint(byte);

@@ -93,0 +93,0 @@ } else {

@@ -5,2 +5,3 @@ "use strict";

const utils = require("./utils.js");
const impl = utils.implSymbol;

@@ -54,2 +55,3 @@

}
if (args[0] !== undefined) {

@@ -81,2 +83,3 @@ if (utils.isObject(args[0])) {

});
V.push(nextItem);

@@ -86,2 +89,3 @@ }

}
V.push(nextItem);

@@ -101,8 +105,11 @@ }

let typedValue = args[0][key];
typedKey = conversions["USVString"](typedKey, {
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s key"
});
typedValue = conversions["USVString"](typedValue, {
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s value"
});
result[typedKey] = typedValue;

@@ -124,2 +131,44 @@ }

Object.defineProperty(URLSearchParams, "prototype", {
value: URLSearchParams.prototype,
writable: false,
enumerable: false,
configurable: false
});
Object.defineProperty(URLSearchParams.prototype, Symbol.iterator, {
writable: true,
enumerable: false,
configurable: true,
value: function entries() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return module.exports.createDefaultIterator(this, "key+value");
}
});
URLSearchParams.prototype.forEach = function 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 'URLSearchParams': 1 argument required, " + "but only 0 present."
);
}
if (typeof callback !== "function") {
throw new TypeError(
"Failed to execute 'forEach' on 'URLSearchParams': 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++;
}
};
URLSearchParams.prototype.append = function append(name, value) {

@@ -129,5 +178,7 @@ if (!this || !module.exports.is(this)) {

}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only " +
"Failed to execute 'append' on 'URLSearchParams': 2 " +
"arguments required, but only " +
arguments.length +

@@ -142,8 +193,11 @@ " present."

}
args[0] = conversions["USVString"](args[0], {
context: "Failed to execute 'append' on 'URLSearchParams': parameter 1"
});
args[1] = conversions["USVString"](args[1], {
context: "Failed to execute 'append' on 'URLSearchParams': parameter 2"
});
return this[impl].append(...args);

@@ -156,5 +210,9 @@ };

}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only " + arguments.length + " present."
"Failed to execute 'delete' on 'URLSearchParams': 1 " +
"argument required, but only " +
arguments.length +
" present."
);

@@ -167,5 +225,7 @@ }

}
args[0] = conversions["USVString"](args[0], {
context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1"
});
return this[impl].delete(...args);

@@ -178,5 +238,9 @@ };

}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only " + arguments.length + " present."
"Failed to execute 'get' on 'URLSearchParams': 1 " +
"argument required, but only " +
arguments.length +
" present."
);

@@ -189,3 +253,5 @@ }

}
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'get' on 'URLSearchParams': parameter 1" });
return this[impl].get(...args);

@@ -198,5 +264,9 @@ };

}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only " + arguments.length + " present."
"Failed to execute 'getAll' on 'URLSearchParams': 1 " +
"argument required, but only " +
arguments.length +
" present."
);

@@ -209,5 +279,7 @@ }

}
args[0] = conversions["USVString"](args[0], {
context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1"
});
return utils.tryWrapperForImpl(this[impl].getAll(...args));

@@ -220,5 +292,9 @@ };

}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only " + arguments.length + " present."
"Failed to execute 'has' on 'URLSearchParams': 1 " +
"argument required, but only " +
arguments.length +
" present."
);

@@ -231,3 +307,5 @@ }

}
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'has' on 'URLSearchParams': parameter 1" });
return this[impl].has(...args);

@@ -240,5 +318,9 @@ };

}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only " + arguments.length + " present."
"Failed to execute 'set' on 'URLSearchParams': 2 " +
"arguments required, but only " +
arguments.length +
" present."
);

@@ -251,4 +333,7 @@ }

}
args[0] = conversions["USVString"](args[0], { context: "Failed to execute 'set' on 'URLSearchParams': parameter 1" });
args[1] = conversions["USVString"](args[1], { context: "Failed to execute 'set' on 'URLSearchParams': parameter 2" });
return this[impl].set(...args);

@@ -261,12 +346,16 @@ };

}
return this[impl].sort();
};
URLSearchParams.prototype[Symbol.iterator] = function entries() {
URLSearchParams.prototype.toString = function toString() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return module.exports.createDefaultIterator(this, "key+value");
return this[impl].toString();
};
URLSearchParams.prototype.entries = URLSearchParams.prototype[Symbol.iterator];
URLSearchParams.prototype.keys = function keys() {

@@ -278,2 +367,3 @@ if (!this || !module.exports.is(this)) {

};
URLSearchParams.prototype.values = function values() {

@@ -285,30 +375,2 @@ if (!this || !module.exports.is(this)) {

};
URLSearchParams.prototype.forEach = function 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 'URLSearchParams': 1 argument required, but only 0 present.");
}
if (typeof callback !== "function") {
throw new TypeError(
"Failed to execute 'forEach' on 'URLSearchParams': 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++;
}
};
URLSearchParams.prototype.toString = function toString() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return utils.tryWrapperForImpl(this[impl].toString());
};

@@ -358,2 +420,3 @@ Object.defineProperty(URLSearchParams.prototype, Symbol.toStringTag, {

},
createDefaultIterator(target, kind) {

@@ -369,5 +432,6 @@ const iterator = Object.create(IteratorPrototype);

},
create(constructorArgs, privateData) {
let obj = Object.create(URLSearchParams.prototype);
this.setup(obj, constructorArgs, privateData);
obj = this.setup(obj, constructorArgs, privateData);
return obj;

@@ -377,3 +441,3 @@ },

let obj = Object.create(URLSearchParams.prototype);
this.setup(obj, constructorArgs, privateData);
obj = this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);

@@ -384,6 +448,6 @@ },

if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
Object.defineProperty(obj, impl, {

@@ -395,12 +459,17 @@ value: new Impl.implementation(constructorArgs, privateData),

});
obj[impl][utils.wrapperSymbol] = obj;
if (Impl.init) {
Impl.init(obj[impl], privateData);
}
return obj;
},
interface: URLSearchParams,
expose: {
Window: { URLSearchParams: URLSearchParams },
Worker: { URLSearchParams: URLSearchParams }
Window: { URLSearchParams },
Worker: { URLSearchParams }
}
};
}; // iface
module.exports = iface;
const Impl = require(".//URLSearchParams-impl.js");

@@ -16,3 +16,3 @@ "use strict";

}
return Buffer.from(bufferSource.buffer, bufferSource.byteOffset, bufferSource.byteLength)
return Buffer.from(bufferSource.buffer, bufferSource.byteOffset, bufferSource.byteLength);
}

@@ -48,3 +48,4 @@

return wrapper[sameObjectCaches][prop] = creator();
wrapper[sameObjectCaches][prop] = creator();
return wrapper[sameObjectCaches][prop];
}

@@ -54,7 +55,7 @@

return impl ? impl[wrapperSymbol] : null;
};
}
function implForWrapper(wrapper) {
return wrapper ? wrapper[implSymbol] : null;
};
}

@@ -64,3 +65,3 @@ function tryWrapperForImpl(impl) {

return wrapper ? wrapper : impl;
};
}

@@ -70,3 +71,3 @@ function tryImplForWrapper(wrapper) {

return impl ? impl : wrapper;
};
}

@@ -76,2 +77,29 @@ const iterInternalSymbol = Symbol("internal");

function isArrayIndexPropName(P) {
if (typeof P !== "string") {
return false;
}
const i = P >>> 0;
if (i === Math.pow(2, 32) - 1) {
return false;
}
const s = `${i}`;
if (P !== s) {
return false;
}
return true;
}
const supportsPropertyIndex = Symbol("supports property index");
const supportedPropertyIndices = Symbol("supported property indices");
const supportsPropertyName = Symbol("supports property name");
const supportedPropertyNames = Symbol("supported property names");
const indexedGet = Symbol("indexed property get");
const indexedSetNew = Symbol("indexed property set new");
const indexedSetExisting = Symbol("indexed property set existing");
const namedGet = Symbol("named property get");
const namedSetNew = Symbol("named property set new");
const namedSetExisting = Symbol("named property set existing");
const namedDelete = Symbol("named property delete");
module.exports = exports = {

@@ -90,3 +118,15 @@ isObject,

iterInternalSymbol,
IteratorPrototype
IteratorPrototype,
isArrayIndexPropName,
supportsPropertyIndex,
supportedPropertyIndices,
supportsPropertyName,
supportedPropertyNames,
indexedGet,
indexedSetNew,
indexedSetExisting,
namedGet,
namedSetNew,
namedSetExisting,
namedDelete
};
{
"name": "whatwg-url",
"version": "6.4.0",
"version": "6.4.1",
"description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery",

@@ -14,14 +14,14 @@ "main": "lib/public-api.js",

"lodash.sortby": "^4.7.0",
"tr46": "^1.0.0",
"webidl-conversions": "^4.0.1"
"tr46": "^1.0.1",
"webidl-conversions": "^4.0.2"
},
"devDependencies": {
"domexception": "^1.0.0",
"eslint": "^4.1.1",
"istanbul": "~0.4.3",
"jest": "^21.0.2",
"jsdom": "^11.0.0",
"recast": "~0.12.6",
"request": "^2.55.0",
"webidl2js": "^7.1.0"
"domexception": "^1.0.1",
"eslint": "^4.19.1",
"istanbul": "~0.4.5",
"jest": "^22.4.3",
"jsdom": "^11.8.0",
"recast": "~0.14.7",
"request": "^2.85.0",
"webidl2js": "^7.4.0"
},

@@ -28,0 +28,0 @@ "scripts": {

@@ -24,3 +24,3 @@ # whatwg-url

- [Serialize an integer](https://url.spec.whatwg.org/#serialize-an-integer): `serializeInteger(number)`
- [Origin](https://url.spec.whatwg.org/#concept-url-origin) [serializer](https://html.spec.whatwg.org/multipage/browsers.html#serialization-of-an-origin): `serializeURLOrigin(urlRecord)`
- [Origin](https://url.spec.whatwg.org/#concept-url-origin) [serializer](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin): `serializeURLOrigin(urlRecord)`
- [Set the username](https://url.spec.whatwg.org/#set-the-username): `setTheUsername(urlRecord, usernameString)`

@@ -27,0 +27,0 @@ - [Set the password](https://url.spec.whatwg.org/#set-the-password): `setThePassword(urlRecord, passwordString)`

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc