Skip to content

Commit 3fef5f6

Browse files
authored
Spec update: changes to file URL path normalization
Follows whatwg/url#544.
1 parent 4282f6c commit 3fef5f6

3 files changed

Lines changed: 6 additions & 18 deletions

File tree

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
## Specification conformance
66

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 [47efa00](https://github.com/whatwg/url/commit/47efa0043d677fb51169cde72b60703bd8de83e3).
88

99
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"`).
1010

scripts/get-latest-platform-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ process.on("unhandledRejection", err => {
2424
// 1. Go to https://github.com/w3c/web-platform-tests/tree/master/url
2525
// 2. Press "y" on your keyboard to get a permalink
2626
// 3. Copy the commit hash
27-
const commitHash = "551c9d604fb8b97d3f8c65793bb047d15baddbc2";
27+
const commitHash = "11a6ab8df5f84d40d8818afe8773dd519e5263e4";
2828

2929
const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`;
3030
const targetDir = path.resolve(__dirname, "..", "test", "web-platform-tests");

src/url-state-machine.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,6 @@ URLStateMachine.prototype["parse file"] = function parseFile(c) {
867867
shortenPath(this.url);
868868
} else {
869869
this.parseError = true;
870-
this.url.host = null;
871870
this.url.path = [];
872871
}
873872

@@ -889,13 +888,12 @@ URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
889888
}
890889
this.state = "file host";
891890
} else {
892-
if (this.base !== null && this.base.scheme === "file" &&
893-
!startsWithWindowsDriveLetter(this.input, this.pointer)) {
894-
if (isNormalizedWindowsDriveLetterString(this.base.path[0])) {
891+
if (this.base !== null && this.base.scheme === "file") {
892+
if (!startsWithWindowsDriveLetter(this.input, this.pointer) &&
893+
isNormalizedWindowsDriveLetterString(this.base.path[0])) {
895894
this.url.path.push(this.base.path[0]);
896-
} else {
897-
this.url.host = this.base.host;
898895
}
896+
this.url.host = this.base.host;
899897
}
900898
this.state = "path";
901899
--this.pointer;
@@ -983,21 +981,11 @@ URLStateMachine.prototype["parse path"] = function parsePath(c) {
983981
this.url.path.push("");
984982
} else if (!isSingleDot(this.buffer)) {
985983
if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) {
986-
if (this.url.host !== "" && this.url.host !== null) {
987-
this.parseError = true;
988-
this.url.host = "";
989-
}
990984
this.buffer = this.buffer[0] + ":";
991985
}
992986
this.url.path.push(this.buffer);
993987
}
994988
this.buffer = "";
995-
if (this.url.scheme === "file" && (c === undefined || c === p("?") || c === p("#"))) {
996-
while (this.url.path.length > 1 && this.url.path[0] === "") {
997-
this.parseError = true;
998-
this.url.path.shift();
999-
}
1000-
}
1001989
if (c === p("?")) {
1002990
this.url.query = "";
1003991
this.state = "query";

0 commit comments

Comments
 (0)