whatwg-url 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/URL-impl.js CHANGED
@@ -143,8 +143,12 @@ exports.implementation = class URLImpl {
143
143
  if (this._url.host === null || this._url.cannotBeABaseURL || this._url.scheme === "file") {
144
144
  return;
145
145
  }
146
-
147
- usm.basicURLParse(v, { url: this._url, stateOverride: "port" });
146
+
147
+ if (v === "") {
148
+ this._url.port = null;
149
+ } else {
150
+ usm.basicURLParse(v, { url: this._url, stateOverride: "port" });
151
+ }
148
152
  }
149
153
 
150
154
  get pathname() {
@@ -424,6 +424,12 @@ function trimTabAndNewline(url) {
424
424
  return url.replace(/\u0009|\u000A|\u000D/g, "");
425
425
  }
426
426
 
427
+ function popPath(url) {
428
+ if (url.scheme !== "file" || !url.path.filter((seg) => /^[A-Za-z](|:)$/.test(seg)).length) {
429
+ url.path.pop();
430
+ }
431
+ }
432
+
427
433
  function URLStateMachine(input, base, encodingOverride, url, stateOverride) {
428
434
  this.pointer = 0;
429
435
  this.input = input;
@@ -828,7 +834,7 @@ URLStateMachine.prototype["parse file"] = function parseFile(c) {
828
834
  [47, 92, 63, 35].indexOf(this.input[this.pointer + 2]) === -1) {
829
835
  this.url.host = this.base.host;
830
836
  this.url.path = this.base.path.slice();
831
- this.url.path.pop();
837
+ popPath(this.url);
832
838
  } else {
833
839
  this.parseError = true;
834
840
  }
@@ -907,7 +913,7 @@ URLStateMachine.prototype["parse path"] = function parsePath(c) {
907
913
  }
908
914
 
909
915
  if (isDoubleDot(this.buffer)) {
910
- this.url.path.pop();
916
+ popPath(this.url);
911
917
  if (c !== 47 && !(specialSchemas[this.url.scheme] !== undefined && c === 92)) {
912
918
  this.url.path.push("");
913
919
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatwg-url",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery",
5
5
  "main": "lib/public-api.js",
6
6
  "author": "Sebastian Mayr <github@smayr.name>",