Socket
Socket
Sign inDemoInstall

whatwg-url

Package Overview
Dependencies
3
Maintainers
6
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 10.0.0 to 11.0.0

2

index.js

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

exports.serializeURL = urlStateMachine.serializeURL;
exports.serializePath = urlStateMachine.serializePath;
exports.serializeHost = urlStateMachine.serializeHost;

@@ -24,4 +25,5 @@ exports.serializeInteger = urlStateMachine.serializeInteger;

exports.cannotHaveAUsernamePasswordPort = urlStateMachine.cannotHaveAUsernamePasswordPort;
exports.hasAnOpaquePath = urlStateMachine.hasAnOpaquePath;
exports.percentDecodeString = percentEncoding.percentDecodeString;
exports.percentDecodeBytes = percentEncoding.percentDecodeBytes;

16

lib/URL-impl.js

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

set host(v) {
if (this._url.cannotBeABaseURL) {
if (usm.hasAnOpaquePath(this._url)) {
return;

@@ -121,3 +121,3 @@ }

set hostname(v) {
if (this._url.cannotBeABaseURL) {
if (usm.hasAnOpaquePath(this._url)) {
return;

@@ -150,15 +150,7 @@ }

get pathname() {
if (this._url.cannotBeABaseURL) {
return this._url.path[0];
}
if (this._url.path.length === 0) {
return "";
}
return `/${this._url.path.join("/")}`;
return usm.serializePath(this._url);
}
set pathname(v) {
if (this._url.cannotBeABaseURL) {
if (usm.hasAnOpaquePath(this._url)) {
return;

@@ -165,0 +157,0 @@ }

@@ -470,5 +470,9 @@ "use strict";

function cannotHaveAUsernamePasswordPort(url) {
return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file";
return url.host === null || url.host === "" || hasAnOpaquePath(url) || url.scheme === "file";
}
function hasAnOpaquePath(url) {
return typeof url.path === "string";
}
function isNormalizedWindowsDriveLetter(string) {

@@ -497,5 +501,3 @@ return /^[A-Za-z]:$/u.test(string);

query: null,
fragment: null,
cannotBeABaseURL: false
fragment: null
};

@@ -597,5 +599,4 @@

} else {
this.url.cannotBeABaseURL = true;
this.url.path.push("");
this.state = "cannot-be-a-base-URL path";
this.url.path = "";
this.state = "opaque path";
}

@@ -615,10 +616,9 @@ } else if (!this.stateOverride) {

URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) {
if (this.base === null || (this.base.cannotBeABaseURL && c !== p("#"))) {
if (this.base === null || (hasAnOpaquePath(this.base) && c !== p("#"))) {
return failure;
} else if (this.base.cannotBeABaseURL && c === p("#")) {
} else if (hasAnOpaquePath(this.base) && c === p("#")) {
this.url.scheme = this.base.scheme;
this.url.path = this.base.path.slice();
this.url.path = this.base.path;
this.url.query = this.base.query;
this.url.fragment = "";
this.url.cannotBeABaseURL = true;
this.state = "fragment";

@@ -1040,3 +1040,3 @@ } else if (this.base.scheme === "file") {

URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) {
URLStateMachine.prototype["parse opaque path"] = function parseOpaquePath(c) {
if (c === p("?")) {

@@ -1061,3 +1061,3 @@ this.url.query = "";

if (!isNaN(c)) {
this.url.path[0] += utf8PercentEncodeCodePoint(c, isC0ControlPercentEncode);
this.url.path += utf8PercentEncodeCodePoint(c, isC0ControlPercentEncode);
}

@@ -1134,12 +1134,6 @@ }

if (url.cannotBeABaseURL) {
output += url.path[0];
} else {
if (url.host === null && url.path.length > 1 && url.path[0] === "") {
output += "/.";
}
for (const segment of url.path) {
output += `/${segment}`;
}
if (url.host === null && !hasAnOpaquePath(url) && url.path.length > 1 && url.path[0] === "") {
output += "/.";
}
output += serializePath(url);

@@ -1168,4 +1162,18 @@ if (url.query !== null) {

function serializePath(url) {
if (hasAnOpaquePath(url)) {
return url.path;
}
let output = "";
for (const segment of url.path) {
output += `/${segment}`;
}
return output;
}
module.exports.serializeURL = serializeURL;
module.exports.serializePath = serializePath;
module.exports.serializeURLOrigin = function (url) {

@@ -1176,3 +1184,3 @@ // https://url.spec.whatwg.org/#concept-url-origin

try {
return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0]));
return module.exports.serializeURLOrigin(module.exports.parseURL(serializePath(url)));
} catch (e) {

@@ -1232,2 +1240,4 @@ // serializing an opaque origin returns "null"

module.exports.hasAnOpaquePath = hasAnOpaquePath;
module.exports.serializeInteger = function (integer) {

@@ -1234,0 +1244,0 @@ return String(integer);

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

@@ -5,0 +5,0 @@ "main": "index.js",

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

whatwg-url is currently up to date with the URL spec up to commit [ab0e820](https://github.com/whatwg/url/commit/ab0e820b0b559610b30c731b7f2c1a8094181680).
whatwg-url is currently up to date with the URL spec up to commit [43c2713](https://github.com/whatwg/url/commit/43c27137a0bc82c4b800fe74be893255fbeb35f4).

@@ -28,2 +28,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"`).

- [Host serializer](https://url.spec.whatwg.org/#concept-host-serializer): `serializeHost(hostFromURLRecord)`
- [URL path serializer](https://url.spec.whatwg.org/#url-path-serializer): `serializePath(urlRecord)`
- [Serialize an integer](https://url.spec.whatwg.org/#serialize-an-integer): `serializeInteger(number)`

@@ -33,2 +34,3 @@ - [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 password](https://url.spec.whatwg.org/#set-the-password): `setThePassword(urlRecord, passwordString)`
- [Has an opaque path](https://url.spec.whatwg.org/#url-opaque-path): `hasAnOpaquePath(urlRecord)`
- [Cannot have a username/password/port](https://url.spec.whatwg.org/#cannot-have-a-username-password-port): `cannotHaveAUsernamePasswordPort(urlRecord)`

@@ -58,3 +60,3 @@ - [Percent decode bytes](https://url.spec.whatwg.org/#percent-decode): `percentDecodeBytes(uint8Array)`

- [`"path"`](https://url.spec.whatwg.org/#path-state)
- [`"cannot-be-a-base-URL path"`](https://url.spec.whatwg.org/#cannot-be-a-base-url-path-state)
- [`"opaque path"`](https://url.spec.whatwg.org/#cannot-be-a-base-url-path-state)
- [`"query"`](https://url.spec.whatwg.org/#query-state)

@@ -70,6 +72,5 @@ - [`"fragment"`](https://url.spec.whatwg.org/#fragment-state)

- [`port`](https://url.spec.whatwg.org/#concept-url-port)
- [`path`](https://url.spec.whatwg.org/#concept-url-path) (as an array)
- [`path`](https://url.spec.whatwg.org/#concept-url-path) (as an array of strings, or a string)
- [`query`](https://url.spec.whatwg.org/#concept-url-query)
- [`fragment`](https://url.spec.whatwg.org/#concept-url-fragment)
- [`cannotBeABaseURL`](https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag) (as a boolean)

@@ -76,0 +77,0 @@ These properties should be treated with care, as in general changing them will cause the URL record to be in an inconsistent state until the appropriate invocation of `basicURLParse` is used to fix it up. You can see examples of this in the URL Standard, where there are many step sequences like "4. Set context object’s url’s fragment to the empty string. 5. Basic URL parse _input_ with context object’s url as _url_ and fragment state as _state override_." In between those two steps, a URL record is in an unusable state.

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