Skip to content

Commit

Permalink
Spec update: changes to file URL path normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
alwinb authored Sep 30, 2020
1 parent 4282f6c commit 3fef5f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ whatwg-url is a full implementation of the WHATWG [URL Standard](https://url.spe

## Specification conformance

whatwg-url is currently up to date with the URL spec up to commit [83adf0c](https://github.com/whatwg/url/commit/83adf0c9ca9a88948e1e5d93374ffded04eec727).
whatwg-url is currently up to date with the URL spec up to commit [47efa00](https://github.com/whatwg/url/commit/47efa0043d677fb51169cde72b60703bd8de83e3).

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

Expand Down
2 changes: 1 addition & 1 deletion scripts/get-latest-platform-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ process.on("unhandledRejection", err => {
// 1. Go to https://github.com/w3c/web-platform-tests/tree/master/url
// 2. Press "y" on your keyboard to get a permalink
// 3. Copy the commit hash
const commitHash = "551c9d604fb8b97d3f8c65793bb047d15baddbc2";
const commitHash = "11a6ab8df5f84d40d8818afe8773dd519e5263e4";

const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`;
const targetDir = path.resolve(__dirname, "..", "test", "web-platform-tests");
Expand Down
20 changes: 4 additions & 16 deletions src/url-state-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,6 @@ URLStateMachine.prototype["parse file"] = function parseFile(c) {
shortenPath(this.url);
} else {
this.parseError = true;
this.url.host = null;
this.url.path = [];
}

Expand All @@ -889,13 +888,12 @@ URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
}
this.state = "file host";
} else {
if (this.base !== null && this.base.scheme === "file" &&
!startsWithWindowsDriveLetter(this.input, this.pointer)) {
if (isNormalizedWindowsDriveLetterString(this.base.path[0])) {
if (this.base !== null && this.base.scheme === "file") {
if (!startsWithWindowsDriveLetter(this.input, this.pointer) &&
isNormalizedWindowsDriveLetterString(this.base.path[0])) {
this.url.path.push(this.base.path[0]);
} else {
this.url.host = this.base.host;
}
this.url.host = this.base.host;
}
this.state = "path";
--this.pointer;
Expand Down Expand Up @@ -983,21 +981,11 @@ URLStateMachine.prototype["parse path"] = function parsePath(c) {
this.url.path.push("");
} else if (!isSingleDot(this.buffer)) {
if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) {
if (this.url.host !== "" && this.url.host !== null) {
this.parseError = true;
this.url.host = "";
}
this.buffer = this.buffer[0] + ":";
}
this.url.path.push(this.buffer);
}
this.buffer = "";
if (this.url.scheme === "file" && (c === undefined || c === p("?") || c === p("#"))) {
while (this.url.path.length > 1 && this.url.path[0] === "") {
this.parseError = true;
this.url.path.shift();
}
}
if (c === p("?")) {
this.url.query = "";
this.state = "query";
Expand Down

0 comments on commit 3fef5f6

Please sign in to comment.