Skip to content

Commit 6ff27fd

Browse files
authored
Spec update: trim leading slashes of file URL paths
Follows whatwg/url#278.
1 parent 084105d commit 6ff27fd

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ whatwg-url is a full implementation of the WHATWG [URL Standard](https://url.spe
44

55
## Current Status
66

7-
whatwg-url is currently up to date with the URL spec up to commit [728656](https://github.com/whatwg/url/commit/72865694ca2fc54b1c5fcfea9bed9f6b34e365ac).
7+
whatwg-url is currently up to date with the URL spec up to commit [a562c5](https://github.com/whatwg/url/commit/a562c55d659e1657d1dc9f9fad600bd9f9d70d82).
88

99
## API
1010

scripts/get-latest-platform-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const request = require("request");
1414
// 1. Go to https://github.com/w3c/web-platform-tests/tree/master/url
1515
// 2. Press "y" on your keyboard to get a permalink
1616
// 3. Copy the commit hash
17-
const commitHash = "e48dd15f848ea7758960fa2dad352253572339c9";
17+
const commitHash = "0444344a4ace9dba478899c92de5a1d6d561cc54";
1818

1919
const sourceURL = `https://raw.githubusercontent.com/w3c/web-platform-tests/${commitHash}/url/urltestdata.json`;
2020
const setterSourceURL = `https://raw.githubusercontent.com/w3c/web-platform-tests/${commitHash}/url/setters_tests.json`;

src/url-state-machine.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,8 +963,10 @@ URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
963963
this.state = "file host";
964964
} else {
965965
if (this.base !== null && this.base.scheme === "file") {
966-
if (this.base.path.length > 0 && isNormalizedWindowsDriveLetterString(this.base.path[0])) {
966+
if (isNormalizedWindowsDriveLetterString(this.base.path[0])) {
967967
this.url.path.push(this.base.path[0]);
968+
} else {
969+
this.url.host = this.base.host;
968970
}
969971
}
970972
this.state = "path";
@@ -1062,6 +1064,12 @@ URLStateMachine.prototype["parse path"] = function parsePath(c) {
10621064
this.url.path.push(this.buffer);
10631065
}
10641066
this.buffer = "";
1067+
if (this.url.scheme === "file" && (c === undefined || c === p("?") || c === p("#"))) {
1068+
while (this.url.path.length > 1 && this.url.path[0] === "") {
1069+
this.parseError = true;
1070+
this.url.path.shift();
1071+
}
1072+
}
10651073
if (c === p("?")) {
10661074
this.url.query = "";
10671075
this.state = "query";

0 commit comments

Comments
 (0)