whatwg-url 8.2.2 → 8.6.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,10 +4,12 @@ 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 [6d4669a](https://github.com/whatwg/url/commit/6d4669a9a8cc90582bdb1e3cdb758e45242812b0).
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
 
11
+ whatwg-url does not yet implement any encoding handling beyond UTF-8. That is, the _encoding override_ parameter does not exist in our API.
12
+
11
13
  ## API
12
14
 
13
15
  ### The `URL` and `URLSearchParams` classes
@@ -18,8 +20,8 @@ The main API is provided by the [`URL`](https://url.spec.whatwg.org/#url-class)
18
20
 
19
21
  The following methods are exported for use by places like jsdom that need to implement things like [`HTMLHyperlinkElementUtils`](https://html.spec.whatwg.org/#htmlhyperlinkelementutils). They mostly operate on or return an "internal URL" or ["URL record"](https://url.spec.whatwg.org/#concept-url) type.
20
22
 
21
- - [URL parser](https://url.spec.whatwg.org/#concept-url-parser): `parseURL(input, { baseURL, encodingOverride })`
22
- - [Basic URL parser](https://url.spec.whatwg.org/#concept-basic-url-parser): `basicURLParse(input, { baseURL, encodingOverride, url, stateOverride })`
23
+ - [URL parser](https://url.spec.whatwg.org/#concept-url-parser): `parseURL(input, { baseURL })`
24
+ - [Basic URL parser](https://url.spec.whatwg.org/#concept-basic-url-parser): `basicURLParse(input, { baseURL, url, stateOverride })`
23
25
  - [URL serializer](https://url.spec.whatwg.org/#concept-url-serializer): `serializeURL(urlRecord, excludeFragment)`
24
26
  - [Host serializer](https://url.spec.whatwg.org/#concept-host-serializer): `serializeHost(hostFromURLRecord)`
25
27
  - [Serialize an integer](https://url.spec.whatwg.org/#serialize-an-integer): `serializeInteger(number)`
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const stableSortBy = require("lodash.sortby");
2
+ const stableSortBy = require("lodash/sortBy");
3
3
  const urlencoded = require("./urlencoded");
4
4
 
5
5
  exports.implementation = class URLSearchParamsImpl {
@@ -50,11 +50,11 @@ function isNormalizedWindowsDriveLetterString(string) {
50
50
  }
51
51
 
52
52
  function containsForbiddenHostCodePoint(string) {
53
- return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|<|>|\?|@|\[|\\|\]|\^/) !== -1;
53
+ return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/) !== -1;
54
54
  }
55
55
 
56
56
  function containsForbiddenHostCodePointExcludingPercent(string) {
57
- return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^/) !== -1;
57
+ return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/) !== -1;
58
58
  }
59
59
 
60
60
  function isSpecialScheme(scheme) {
@@ -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
  }
@@ -756,6 +756,10 @@ URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) {
756
756
  return failure;
757
757
  }
758
758
 
759
+ if (this.stateOverride === "hostname") {
760
+ return false;
761
+ }
762
+
759
763
  const host = parseHost(this.buffer, isNotSpecial(this.url));
760
764
  if (host === failure) {
761
765
  return failure;
@@ -764,9 +768,6 @@ URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) {
764
768
  this.url.host = host;
765
769
  this.buffer = "";
766
770
  this.state = "port";
767
- if (this.stateOverride === "hostname") {
768
- return false;
769
- }
770
771
  } else if (isNaN(c) || c === 47 || c === 63 || c === 35 ||
771
772
  (isSpecial(this.url) && c === 92)) {
772
773
  --this.pointer;
@@ -841,6 +842,7 @@ function startsWithWindowsDriveLetter(input, pointer) {
841
842
 
842
843
  URLStateMachine.prototype["parse file"] = function parseFile(c) {
843
844
  this.url.scheme = "file";
845
+ this.url.host = "";
844
846
 
845
847
  if (c === 47 || c === 92) {
846
848
  if (c === 92) {
@@ -863,7 +865,6 @@ URLStateMachine.prototype["parse file"] = function parseFile(c) {
863
865
  shortenPath(this.url);
864
866
  } else {
865
867
  this.parseError = true;
866
- this.url.host = null;
867
868
  this.url.path = [];
868
869
  }
869
870
 
@@ -885,13 +886,12 @@ URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
885
886
  }
886
887
  this.state = "file host";
887
888
  } else {
888
- if (this.base !== null && this.base.scheme === "file" &&
889
- !startsWithWindowsDriveLetter(this.input, this.pointer)) {
890
- if (isNormalizedWindowsDriveLetterString(this.base.path[0])) {
889
+ if (this.base !== null && this.base.scheme === "file") {
890
+ if (!startsWithWindowsDriveLetter(this.input, this.pointer) &&
891
+ isNormalizedWindowsDriveLetterString(this.base.path[0])) {
891
892
  this.url.path.push(this.base.path[0]);
892
- } else {
893
- this.url.host = this.base.host;
894
893
  }
894
+ this.url.host = this.base.host;
895
895
  }
896
896
  this.state = "path";
897
897
  --this.pointer;
@@ -979,21 +979,11 @@ URLStateMachine.prototype["parse path"] = function parsePath(c) {
979
979
  this.url.path.push("");
980
980
  } else if (!isSingleDot(this.buffer)) {
981
981
  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
982
  this.buffer = this.buffer[0] + ":";
987
983
  }
988
984
  this.url.path.push(this.buffer);
989
985
  }
990
986
  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
987
  if (c === 63) {
998
988
  this.url.query = "";
999
989
  this.state = "query";
@@ -1044,14 +1034,21 @@ URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCan
1044
1034
  return true;
1045
1035
  };
1046
1036
 
1047
- URLStateMachine.prototype["parse query"] = function parseQuery(c) {
1037
+ URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) {
1048
1038
  if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") {
1049
1039
  this.encodingOverride = "utf-8";
1050
1040
  }
1051
1041
 
1052
- if (!this.stateOverride & c === 35) {
1053
- this.url.fragment = "";
1054
- this.state = "fragment";
1042
+ if ((!this.stateOverride && c === 35) || isNaN(c)) {
1043
+ const queryPercentEncodePredicate = isSpecial(this.url) ? isSpecialQueryPercentEncode : isQueryPercentEncode;
1044
+ this.url.query += utf8PercentEncodeString(this.buffer, queryPercentEncodePredicate);
1045
+
1046
+ this.buffer = "";
1047
+
1048
+ if (c === 35) {
1049
+ this.url.fragment = "";
1050
+ this.state = "fragment";
1051
+ }
1055
1052
  } else if (!isNaN(c)) {
1056
1053
  // TODO: If c is not a URL code point and not "%", parse error.
1057
1054
 
@@ -1061,9 +1058,7 @@ URLStateMachine.prototype["parse query"] = function parseQuery(c) {
1061
1058
  this.parseError = true;
1062
1059
  }
1063
1060
 
1064
- const queryPercentEncodePredicate = isSpecial(this.url) ? isSpecialQueryPercentEncode : isQueryPercentEncode;
1065
- // TODO: use "percent-encode after encoding" passing in this.encodingOverride
1066
- this.url.query += utf8PercentEncodeCodePoint(c, queryPercentEncodePredicate);
1061
+ this.buffer += cStr;
1067
1062
  }
1068
1063
 
1069
1064
  return true;
@@ -1102,8 +1097,6 @@ function serializeURL(url, excludeFragment) {
1102
1097
  if (url.port !== null) {
1103
1098
  output += ":" + url.port;
1104
1099
  }
1105
- } else if (url.host === null && url.scheme === "file") {
1106
- output += "//";
1107
1100
  }
1108
1101
 
1109
1102
  if (url.cannotBeABaseURL) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatwg-url",
3
- "version": "8.2.2",
3
+ "version": "8.6.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": [
@@ -12,18 +12,18 @@
12
12
  "license": "MIT",
13
13
  "repository": "jsdom/whatwg-url",
14
14
  "dependencies": {
15
- "lodash.sortby": "^4.7.0",
16
- "tr46": "^2.0.2",
15
+ "lodash": "^4.7.0",
16
+ "tr46": "^2.1.0",
17
17
  "webidl-conversions": "^6.1.0"
18
18
  },
19
19
  "devDependencies": {
20
- "browserify": "^16.5.2",
20
+ "browserify": "^17.0.0",
21
21
  "domexception": "^2.0.1",
22
- "eslint": "^7.7.0",
23
- "glob": "^7.1.6",
24
- "got": "^11.5.2",
25
- "jest": "^26.4.2",
26
- "recast": "^0.20.2",
22
+ "eslint": "^7.28.0",
23
+ "glob": "^7.1.7",
24
+ "got": "^11.8.2",
25
+ "jest": "^27.0.4",
26
+ "recast": "^0.20.4",
27
27
  "webidl2js": "^16.2.0"
28
28
  },
29
29
  "engines": {