whatwg-url 6.0.1 → 6.3.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 +1 -1
- package/lib/URLSearchParams-impl.js +5 -1
- package/lib/url-state-machine.js +32 -10
- package/package.json +27 -7
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
|
## Current status
|
|
6
6
|
|
|
7
|
-
whatwg-url is currently up to date with the URL spec up to commit [
|
|
7
|
+
whatwg-url is currently up to date with the URL spec up to commit [2eef975](https://github.com/whatwg/url/commit/2eef975e989cb5ae2d62467394778fd6778ddec9).
|
|
8
8
|
|
|
9
9
|
## API
|
|
10
10
|
|
|
@@ -32,7 +32,11 @@ exports.implementation = class URLSearchParamsImpl {
|
|
|
32
32
|
|
|
33
33
|
_updateSteps() {
|
|
34
34
|
if (this._url !== null) {
|
|
35
|
-
|
|
35
|
+
let query = urlencoded.serializeUrlencoded(this._list);
|
|
36
|
+
if (query === "") {
|
|
37
|
+
query = null;
|
|
38
|
+
}
|
|
39
|
+
this._url._url.query = query;
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
|
package/lib/url-state-machine.js
CHANGED
|
@@ -68,7 +68,7 @@ function defaultPort(scheme) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
function utf8PercentEncode(c) {
|
|
71
|
-
const buf =
|
|
71
|
+
const buf = Buffer.from(c);
|
|
72
72
|
|
|
73
73
|
let str = "";
|
|
74
74
|
|
|
@@ -360,8 +360,8 @@ function parseHost(input, isSpecialArg) {
|
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
const domain = percentDecode(Buffer.from(input)).toString();
|
|
363
|
-
const asciiDomain =
|
|
364
|
-
if (asciiDomain ===
|
|
363
|
+
const asciiDomain = domainToASCII(domain);
|
|
364
|
+
if (asciiDomain === failure) {
|
|
365
365
|
return failure;
|
|
366
366
|
}
|
|
367
367
|
|
|
@@ -438,6 +438,20 @@ function serializeHost(host) {
|
|
|
438
438
|
return host;
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
+
function domainToASCII(domain, beStrict = false) {
|
|
442
|
+
const result = tr46.toASCII(domain, {
|
|
443
|
+
checkBidi: true,
|
|
444
|
+
checkHyphens: false,
|
|
445
|
+
checkJoiners: true,
|
|
446
|
+
useSTD3ASCIIRules: beStrict,
|
|
447
|
+
verifyDNSLength: beStrict
|
|
448
|
+
});
|
|
449
|
+
if (result === null) {
|
|
450
|
+
return failure;
|
|
451
|
+
}
|
|
452
|
+
return result;
|
|
453
|
+
}
|
|
454
|
+
|
|
441
455
|
function trimControlChars(url) {
|
|
442
456
|
return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, "");
|
|
443
457
|
}
|
|
@@ -568,10 +582,13 @@ URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) {
|
|
|
568
582
|
}
|
|
569
583
|
}
|
|
570
584
|
this.url.scheme = this.buffer;
|
|
571
|
-
this.buffer = "";
|
|
572
585
|
if (this.stateOverride) {
|
|
586
|
+
if (this.url.port === defaultPort(this.url.scheme)) {
|
|
587
|
+
this.url.port = null;
|
|
588
|
+
}
|
|
573
589
|
return false;
|
|
574
590
|
}
|
|
591
|
+
this.buffer = "";
|
|
575
592
|
if (this.url.scheme === "file") {
|
|
576
593
|
if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) {
|
|
577
594
|
this.parseError = true;
|
|
@@ -863,6 +880,13 @@ URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) {
|
|
|
863
880
|
|
|
864
881
|
const fileOtherwiseCodePoints = new Set([47, 92, 63, 35]);
|
|
865
882
|
|
|
883
|
+
function startsWithWindowsDriveLetter(input, pointer) {
|
|
884
|
+
const length = input.length - pointer;
|
|
885
|
+
return length >= 2 &&
|
|
886
|
+
isWindowsDriveLetterCodePoints(input[pointer], input[pointer + 1]) &&
|
|
887
|
+
(length === 2 || fileOtherwiseCodePoints.has(input[pointer + 2]));
|
|
888
|
+
}
|
|
889
|
+
|
|
866
890
|
URLStateMachine.prototype["parse file"] = function parseFile(c) {
|
|
867
891
|
this.url.scheme = "file";
|
|
868
892
|
|
|
@@ -888,10 +912,7 @@ URLStateMachine.prototype["parse file"] = function parseFile(c) {
|
|
|
888
912
|
this.url.fragment = "";
|
|
889
913
|
this.state = "fragment";
|
|
890
914
|
} else {
|
|
891
|
-
if (this.input
|
|
892
|
-
!isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) ||
|
|
893
|
-
(this.input.length - this.pointer - 1 >= 2 && // remaining has at least 2 code points
|
|
894
|
-
!fileOtherwiseCodePoints.has(this.input[this.pointer + 2]))) {
|
|
915
|
+
if (!startsWithWindowsDriveLetter(this.input, this.pointer)) {
|
|
895
916
|
this.url.host = this.base.host;
|
|
896
917
|
this.url.path = this.base.path.slice();
|
|
897
918
|
shortenPath(this.url);
|
|
@@ -917,7 +938,8 @@ URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
|
|
|
917
938
|
}
|
|
918
939
|
this.state = "file host";
|
|
919
940
|
} else {
|
|
920
|
-
if (this.base !== null && this.base.scheme === "file"
|
|
941
|
+
if (this.base !== null && this.base.scheme === "file" &&
|
|
942
|
+
!startsWithWindowsDriveLetter(this.input, this.pointer)) {
|
|
921
943
|
if (isNormalizedWindowsDriveLetterString(this.base.path[0])) {
|
|
922
944
|
this.url.path.push(this.base.path[0]);
|
|
923
945
|
} else {
|
|
@@ -1081,7 +1103,7 @@ URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) {
|
|
|
1081
1103
|
this.encodingOverride = "utf-8";
|
|
1082
1104
|
}
|
|
1083
1105
|
|
|
1084
|
-
const buffer =
|
|
1106
|
+
const buffer = Buffer.from(this.buffer); // TODO: Use encoding override instead
|
|
1085
1107
|
for (let i = 0; i < buffer.length; ++i) {
|
|
1086
1108
|
if (buffer[i] < 0x21 || buffer[i] > 0x7E || buffer[i] === 0x22 || buffer[i] === 0x23 ||
|
|
1087
1109
|
buffer[i] === 0x3C || buffer[i] === 0x3E) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whatwg-url",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.3.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
|
"files": [
|
|
@@ -11,24 +11,44 @@
|
|
|
11
11
|
"repository": "jsdom/whatwg-url",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"lodash.sortby": "^4.7.0",
|
|
14
|
-
"tr46": "
|
|
14
|
+
"tr46": "^1.0.0",
|
|
15
15
|
"webidl-conversions": "^4.0.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
+
"domexception": "^1.0.0",
|
|
18
19
|
"eslint": "^4.1.1",
|
|
19
20
|
"istanbul": "~0.4.3",
|
|
21
|
+
"jest": "^21.0.2",
|
|
20
22
|
"jsdom": "^11.0.0",
|
|
21
|
-
"mocha": "^3.4.2",
|
|
22
23
|
"recast": "~0.12.6",
|
|
23
24
|
"request": "^2.55.0",
|
|
24
25
|
"webidl2js": "^7.1.0"
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
28
|
"build": "node scripts/transform.js && node scripts/convert-idl.js",
|
|
28
|
-
"coverage": "
|
|
29
|
+
"coverage": "jest --coverage",
|
|
29
30
|
"lint": "eslint .",
|
|
30
|
-
"prepublish": "
|
|
31
|
-
"pretest": "node scripts/get-latest-platform-tests.js &&
|
|
32
|
-
"test": "
|
|
31
|
+
"prepublish": "node scripts/transform.js && node scripts/convert-idl.js",
|
|
32
|
+
"pretest": "node scripts/get-latest-platform-tests.js && node scripts/transform.js && node scripts/convert-idl.js",
|
|
33
|
+
"test": "jest"
|
|
34
|
+
},
|
|
35
|
+
"jest": {
|
|
36
|
+
"collectCoverageFrom": [
|
|
37
|
+
"lib/**/*.js",
|
|
38
|
+
"!lib/utils.js"
|
|
39
|
+
],
|
|
40
|
+
"coverageDirectory": "coverage",
|
|
41
|
+
"coverageReporters": [
|
|
42
|
+
"lcov",
|
|
43
|
+
"text-summary"
|
|
44
|
+
],
|
|
45
|
+
"testEnvironment": "node",
|
|
46
|
+
"testMatch": [
|
|
47
|
+
"<rootDir>/test/**/*.js"
|
|
48
|
+
],
|
|
49
|
+
"testPathIgnorePatterns": [
|
|
50
|
+
"^<rootDir>/test/testharness.js$",
|
|
51
|
+
"^<rootDir>/test/web-platform-tests/"
|
|
52
|
+
]
|
|
33
53
|
}
|
|
34
54
|
}
|