Skip to content

Commit

Permalink
Spec update: trim leading slashes of file URL paths
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Mar 29, 2017
1 parent 084105d commit 38e32cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/get-latest-platform-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const request = require("request");
// 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 = "e48dd15f848ea7758960fa2dad352253572339c9";
const commitHash = "0c50fd6f360ebcd1b43f197182c9434de34b8c56";

const sourceURL = `https://raw.githubusercontent.com/w3c/web-platform-tests/${commitHash}/url/urltestdata.json`;
const setterSourceURL = `https://raw.githubusercontent.com/w3c/web-platform-tests/${commitHash}/url/setters_tests.json`;
Expand Down
10 changes: 9 additions & 1 deletion src/url-state-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,8 +963,10 @@ URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {
this.state = "file host";
} else {
if (this.base !== null && this.base.scheme === "file") {
if (this.base.path.length > 0 && isNormalizedWindowsDriveLetterString(this.base.path[0])) {
if (isNormalizedWindowsDriveLetterString(this.base.path[0])) {
this.url.path.push(this.base.path[0]);
} else {
this.url.host = this.base.host;
}
}
this.state = "path";
Expand Down Expand Up @@ -1062,6 +1064,12 @@ URLStateMachine.prototype["parse path"] = function parsePath(c) {
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 38e32cc

Please sign in to comment.