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 Apr 3, 2017
1 parent 084105d commit 6ff27fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 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

## Current Status

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

## API

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 @@ -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 = "0444344a4ace9dba478899c92de5a1d6d561cc54";

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 6ff27fd

Please sign in to comment.