🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

whatwg-url

Package Overview
Dependencies
Maintainers
6
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatwg-url - npm Package Compare versions

Comparing version

to
14.1.0

13

lib/URL-impl.js

@@ -9,6 +9,3 @@ "use strict";

// messages in the constructor that distinguish between the different causes of failure.
constructor(globalObject, constructorArgs) {
const url = constructorArgs[0];
const base = constructorArgs[1];
constructor(globalObject, [url, base]) {
let parsedBase = null;

@@ -37,2 +34,10 @@ if (base !== undefined) {

static parse(globalObject, input, base) {
try {
return new URLImpl(globalObject, [input, base]);
} catch {
return null;
}
}
static canParse(url, base) {

@@ -39,0 +44,0 @@ let parsedBase = null;

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

let output = "";
const compress = findLongestZeroSequence(address);
const compress = findTheIPv6AddressCompressedPieceIndex(address);
let ignore0 = false;

@@ -329,3 +329,3 @@

function parseHost(input, isNotSpecialArg = false) {
function parseHost(input, isOpaque = false) {
if (input[0] === "[") {

@@ -339,3 +339,3 @@ if (input[input.length - 1] !== "]") {

if (isNotSpecialArg) {
if (isOpaque) {
return parseOpaqueHost(input);

@@ -390,31 +390,30 @@ }

function findLongestZeroSequence(arr) {
let maxIdx = null;
let maxLen = 1; // only find elements > 1
let currStart = null;
let currLen = 0;
function findTheIPv6AddressCompressedPieceIndex(address) {
let longestIndex = null;
let longestSize = 1; // only find elements > 1
let foundIndex = null;
let foundSize = 0;
for (let i = 0; i < arr.length; ++i) {
if (arr[i] !== 0) {
if (currLen > maxLen) {
maxIdx = currStart;
maxLen = currLen;
for (let pieceIndex = 0; pieceIndex < address.length; ++pieceIndex) {
if (address[pieceIndex] !== 0) {
if (foundSize > longestSize) {
longestIndex = foundIndex;
longestSize = foundSize;
}
currStart = null;
currLen = 0;
foundIndex = null;
foundSize = 0;
} else {
if (currStart === null) {
currStart = i;
if (foundIndex === null) {
foundIndex = pieceIndex;
}
++currLen;
++foundSize;
}
}
// if trailing zeros
if (currLen > maxLen) {
return currStart;
if (foundSize > longestSize) {
return foundIndex;
}
return maxIdx;
return longestIndex;
}

@@ -421,0 +420,0 @@

@@ -408,2 +408,30 @@ "use strict";

static parse(url) {
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'parse' on 'URL': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'parse' on 'URL': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'parse' on 'URL': parameter 2",
globals: globalObject
});
}
args.push(curArg);
}
return utils.tryWrapperForImpl(Impl.implementation.parse(globalObject, ...args));
}
static canParse(url) {

@@ -454,3 +482,3 @@ if (arguments.length < 1) {

});
Object.defineProperties(URL, { canParse: { enumerable: true } });
Object.defineProperties(URL, { parse: { enumerable: true }, canParse: { enumerable: true } });
ctorRegistry[interfaceName] = URL;

@@ -457,0 +485,0 @@

{
"name": "whatwg-url",
"version": "14.0.0",
"version": "14.1.0",
"description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery",

@@ -19,9 +19,9 @@ "main": "index.js",

"devDependencies": {
"@domenic/eslint-config": "^3.0.0",
"@domenic/eslint-config": "^4.0.1",
"benchmark": "^2.1.4",
"c8": "^8.0.1",
"domexception": "^4.0.0",
"esbuild": "^0.19.5",
"eslint": "^8.53.0",
"webidl2js": "^17.1.0"
"c8": "^10.1.2",
"esbuild": "^0.24.0",
"eslint": "^9.16.0",
"globals": "^15.13.0",
"webidl2js": "^18.0.0"
},

@@ -33,3 +33,3 @@ "engines": {

"coverage": "c8 node --test --experimental-test-coverage test/*.js",
"lint": "eslint .",
"lint": "eslint",
"prepare": "node scripts/transform.js",

@@ -36,0 +36,0 @@ "pretest": "node scripts/get-latest-platform-tests.js && node scripts/transform.js",

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

whatwg-url is currently up to date with the URL spec up to commit [eee49fd](https://github.com/whatwg/url/commit/eee49fdf4f99d59f717cbeb0bce29fda930196d4).
whatwg-url is currently up to date with the URL spec up to commit [da212c9](https://github.com/whatwg/url/commit/da212c98f0bba9c35aec3728bbcc13f8f3a7eb52).

@@ -36,3 +36,3 @@ For `file:` URLs, whose [origin is left unspecified](https://url.spec.whatwg.org/#concept-url-origin), whatwg-url chooses to use a new opaque origin (which serializes to `"null"`).

- [Percent decode bytes](https://url.spec.whatwg.org/#percent-decode): `percentDecodeBytes(uint8Array)`
- [Percent decode a string](https://url.spec.whatwg.org/#percent-decode-string): `percentDecodeString(string)`
- [Percent decode a string](https://url.spec.whatwg.org/#string-percent-decode): `percentDecodeString(string)`

@@ -39,0 +39,0 @@ The `stateOverride` parameter is one of the following strings: