whatwg-url 8.2.0 → 8.4.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/README.md CHANGED
@@ -4,7 +4,7 @@ whatwg-url is a full implementation of the WHATWG [URL Standard](https://url.spe
4
4
 
5
5
  ## Specification conformance
6
6
 
7
- whatwg-url is currently up to date with the URL spec up to commit [83adf0c](https://github.com/whatwg/url/commit/83adf0c9ca9a88948e1e5d93374ffded04eec727).
7
+ whatwg-url is currently up to date with the URL spec up to commit [a19495e](https://github.com/whatwg/url/commit/a19495e27ad95154543b46f751d1a1bf25553808).
8
8
 
9
9
  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"`).
10
10
 
@@ -29,7 +29,10 @@ function percentDecodeBytes(input) {
29
29
  }
30
30
  }
31
31
 
32
- return output.slice(0, outputIndex);
32
+ // TODO: remove the Buffer.from in the next major version; it's only needed for back-compat, and sticking to standard
33
+ // typed arrays is nicer and simpler.
34
+ // See https://github.com/jsdom/data-urls/issues/17 for background.
35
+ return Buffer.from(output.slice(0, outputIndex));
33
36
  }
34
37
 
35
38
  // https://url.spec.whatwg.org/#string-percent-decode
@@ -543,7 +543,7 @@ URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) {
543
543
  return false;
544
544
  }
545
545
 
546
- if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) {
546
+ if (this.url.scheme === "file" && this.url.host === "") {
547
547
  return false;
548
548
  }
549
549
  }
@@ -841,6 +841,7 @@ function startsWithWindowsDriveLetter(input, pointer) {
841
841
 
842
842
  URLStateMachine.prototype["parse file"] = function parseFile(c) {
843
843
  this.url.scheme = "file";
844
+ this.url.host = "";
844
845
 
845
846
  if (c === 47 || c === 92) {
846
847
  if (c === 92) {
@@ -863,7 +864,6 @@ URLStateMachine.prototype["parse file"] = function parseFile(c) {
863
864
  shortenPath(this.url);
864
865
  } else {
865
866
  this.parseError = true;
866
- this.url.host = null;
867
867
  this.url.path = [];
868
868
  }
869
869
 
@@ -885,13 +885,12 @@ URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
885
885
  }
886
886
  this.state = "file host";
887
887
  } else {
888
- if (this.base !== null && this.base.scheme === "file" &&
889
- !startsWithWindowsDriveLetter(this.input, this.pointer)) {
890
- if (isNormalizedWindowsDriveLetterString(this.base.path[0])) {
888
+ if (this.base !== null && this.base.scheme === "file") {
889
+ if (!startsWithWindowsDriveLetter(this.input, this.pointer) &&
890
+ isNormalizedWindowsDriveLetterString(this.base.path[0])) {
891
891
  this.url.path.push(this.base.path[0]);
892
- } else {
893
- this.url.host = this.base.host;
894
892
  }
893
+ this.url.host = this.base.host;
895
894
  }
896
895
  this.state = "path";
897
896
  --this.pointer;
@@ -979,21 +978,11 @@ URLStateMachine.prototype["parse path"] = function parsePath(c) {
979
978
  this.url.path.push("");
980
979
  } else if (!isSingleDot(this.buffer)) {
981
980
  if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) {
982
- if (this.url.host !== "" && this.url.host !== null) {
983
- this.parseError = true;
984
- this.url.host = "";
985
- }
986
981
  this.buffer = this.buffer[0] + ":";
987
982
  }
988
983
  this.url.path.push(this.buffer);
989
984
  }
990
985
  this.buffer = "";
991
- if (this.url.scheme === "file" && (c === undefined || c === 63 || c === 35)) {
992
- while (this.url.path.length > 1 && this.url.path[0] === "") {
993
- this.parseError = true;
994
- this.url.path.shift();
995
- }
996
- }
997
986
  if (c === 63) {
998
987
  this.url.query = "";
999
988
  this.state = "query";
@@ -1102,8 +1091,6 @@ function serializeURL(url, excludeFragment) {
1102
1091
  if (url.port !== null) {
1103
1092
  output += ":" + url.port;
1104
1093
  }
1105
- } else if (url.host === null && url.scheme === "file") {
1106
- output += "//";
1107
1094
  }
1108
1095
 
1109
1096
  if (url.cannotBeABaseURL) {
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { URL, URLSearchParams } = require("./webidl2js-wrapper");
4
4
  const urlStateMachine = require("./dist/url-state-machine");
5
- const urlEncoded = require("./dist/urlencoded");
5
+ const percentEncoding = require("./dist/percent-encoding");
6
6
 
7
7
  const sharedGlobalObject = {};
8
8
  URL.install(sharedGlobalObject, ["Window"]);
@@ -21,4 +21,4 @@ exports.setTheUsername = urlStateMachine.setTheUsername;
21
21
  exports.setThePassword = urlStateMachine.setThePassword;
22
22
  exports.cannotHaveAUsernamePasswordPort = urlStateMachine.cannotHaveAUsernamePasswordPort;
23
23
 
24
- exports.percentDecode = urlEncoded.percentDecode;
24
+ exports.percentDecode = percentEncoding.percentDecodeBytes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatwg-url",
3
- "version": "8.2.0",
3
+ "version": "8.4.0",
4
4
  "description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery",
5
5
  "main": "index.js",
6
6
  "files": [