Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

whatwg-url

Package Overview
Dependencies
Maintainers
2
Versions
63
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 4.8.0 to 5.0.0

2

lib/public-api.js

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

exports.serializeURL = require("./url-state-machine").serializeURL;
exports.serializeURLToUnicodeOrigin = require("./url-state-machine").serializeURLToUnicodeOrigin;
exports.serializeURLOrigin = require("./url-state-machine").serializeURLOrigin;
exports.basicURLParse = require("./url-state-machine").basicURLParse;

@@ -8,0 +8,0 @@ exports.setTheUsername = require("./url-state-machine").setTheUsername;

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

get origin() {
return usm.serializeURLToUnicodeOrigin(this._url);
return usm.serializeURLOrigin(this._url);
}

@@ -44,0 +44,0 @@

@@ -217,5 +217,5 @@ "use strict";

for (let i = 0; i < 4; ++i) {
for (let i = 1; i <= 4; ++i) {
output = String(n % 256) + output;
if (i !== 3) {
if (i !== 4) {
output = "." + output;

@@ -230,5 +230,5 @@ }

function parseIPv6(input) {
const ip = [0, 0, 0, 0, 0, 0, 0, 0];
let piecePtr = 0;
let compressPtr = null;
const address = [0, 0, 0, 0, 0, 0, 0, 0];
let pieceIndex = 0;
let compress = null;
let pointer = 0;

@@ -244,8 +244,8 @@

pointer += 2;
++piecePtr;
compressPtr = piecePtr;
++pieceIndex;
compress = pieceIndex;
}
while (pointer < input.length) {
if (piecePtr === 8) {
if (pieceIndex === 8) {
return failure;

@@ -255,8 +255,8 @@ }

if (input[pointer] === 58) {
if (compressPtr !== null) {
if (compress !== null) {
return failure;
}
++pointer;
++piecePtr;
compressPtr = piecePtr;
++pieceIndex;
compress = pieceIndex;
continue;

@@ -281,3 +281,3 @@ }

if (piecePtr > 6) {
if (pieceIndex > 6) {
return failure;

@@ -318,3 +318,3 @@ }

ip[piecePtr] = ip[piecePtr] * 0x100 + ipv4Piece;
address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece;

@@ -324,3 +324,3 @@ ++numbersSeen;

if (numbersSeen === 2 || numbersSeen === 4) {
++piecePtr;
++pieceIndex;
}

@@ -343,21 +343,21 @@ }

ip[piecePtr] = value;
++piecePtr;
address[pieceIndex] = value;
++pieceIndex;
}
if (compressPtr !== null) {
let swaps = piecePtr - compressPtr;
piecePtr = 7;
while (piecePtr !== 0 && swaps > 0) {
const temp = ip[compressPtr + swaps - 1]; // piece
ip[compressPtr + swaps - 1] = ip[piecePtr];
ip[piecePtr] = temp;
--piecePtr;
if (compress !== null) {
let swaps = pieceIndex - compress;
pieceIndex = 7;
while (pieceIndex !== 0 && swaps > 0) {
const temp = address[compress + swaps - 1];
address[compress + swaps - 1] = address[pieceIndex];
address[pieceIndex] = temp;
--pieceIndex;
--swaps;
}
} else if (compressPtr === null && piecePtr !== 8) {
} else if (compress === null && pieceIndex !== 8) {
return failure;
}
return ip;
return address;
}

@@ -368,9 +368,7 @@

const seqResult = findLongestZeroSequence(address);
const compressPtr = seqResult.idx;
const compress = seqResult.idx;
let ignore0 = false;
for (let i = 0; i < address.length; ++i) {
const piece = address[i];
if (ignore0 && piece === 0) {
for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) {
if (ignore0 && address[pieceIndex] === 0) {
continue;

@@ -381,4 +379,4 @@ } else if (ignore0) {

if (compressPtr === i) {
const separator = i === 0 ? "::" : ":";
if (compress === pieceIndex) {
const separator = pieceIndex === 0 ? "::" : ":";
output += separator;

@@ -389,5 +387,5 @@ ignore0 = true;

output += piece.toString(16);
output += address[pieceIndex].toString(16);
if (i !== address.length - 1) {
if (pieceIndex !== 7) {
output += ":";

@@ -1224,8 +1222,4 @@ }

function serializeOrigin(tuple) {
if (tuple.scheme === undefined || tuple.host === undefined || tuple.port === undefined) {
return "null";
}
let result = tuple.scheme + "://";
result += tr46.toUnicode(tuple.host, false).domain;
result += serializeHost(tuple.host);

@@ -1241,9 +1235,10 @@ if (tuple.port !== null) {

module.exports.serializeURLToUnicodeOrigin = function (url) {
module.exports.serializeURLOrigin = function (url) {
// https://url.spec.whatwg.org/#concept-url-origin
switch (url.scheme) {
case "blob":
try {
return module.exports.serializeURLToUnicodeOrigin(module.exports.parseURL(url.path[0]));
return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0]));
} catch (e) {
// serializing an opaque identifier returns "null"
// serializing an opaque origin returns "null"
return "null";

@@ -1259,3 +1254,3 @@ }

scheme: url.scheme,
host: serializeHost(url.host),
host: url.host,
port: url.port

@@ -1267,3 +1262,3 @@ });

default:
// serializing an opaque identifier returns "null"
// serializing an opaque origin returns "null"
return "null";

@@ -1270,0 +1265,0 @@ }

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

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

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

whatwg-url is currently up to date with the URL spec up to commit [fe6b25](https://github.com/whatwg/url/commit/fe6b251739e225555f04319f19c70c031a5d99eb).
whatwg-url is currently up to date with the URL spec up to commit [a62223](https://github.com/whatwg/url/commit/a622235308342c9adc7fc2fd1659ff059f7d5e2a).

@@ -25,3 +25,3 @@ ## API

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

@@ -28,0 +28,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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc