From 515b277ba5b8a0665fd10f2cb741dac522e0a634 Mon Sep 17 00:00:00 2001 From: Alwin Blok Date: Wed, 23 Sep 2020 11:38:30 +0200 Subject: [PATCH 1/4] Implement proposal for file URL path normalisation --- scripts/get-latest-platform-tests.js | 7 +++++-- src/url-state-machine.js | 22 +++++----------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/scripts/get-latest-platform-tests.js b/scripts/get-latest-platform-tests.js index cdbad15..9b218d1 100644 --- a/scripts/get-latest-platform-tests.js +++ b/scripts/get-latest-platform-tests.js @@ -24,9 +24,12 @@ 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 = "551c9d604fb8b97d3f8c65793bb047d15baddbc2"; +// const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`; + +const commitHash = "094fcd4dd2b881a7f751f9c1f55534cbe08b151f"; +const urlPrefix = `https://raw.githubusercontent.com/alwinb/wpt/${commitHash}/url/`; -const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`; const targetDir = path.resolve(__dirname, "..", "test", "web-platform-tests"); clearDir(targetDir); diff --git a/src/url-state-machine.js b/src/url-state-machine.js index 21976d6..c514ec9 100644 --- a/src/url-state-machine.js +++ b/src/url-state-machine.js @@ -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 = []; } @@ -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])) { - this.url.path.push(this.base.path[0]); - } else { - this.url.host = this.base.host; + 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]); } + this.url.host = this.base.host; } this.state = "path"; --this.pointer; @@ -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"; From c419672c26b5c0deb6491d6171feda786f309ca1 Mon Sep 17 00:00:00 2001 From: Alwin Blok Date: Wed, 23 Sep 2020 17:24:10 +0200 Subject: [PATCH 2/4] Make npm run lint pass --- src/url-state-machine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/url-state-machine.js b/src/url-state-machine.js index c514ec9..2e06e24 100644 --- a/src/url-state-machine.js +++ b/src/url-state-machine.js @@ -891,7 +891,7 @@ URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) { 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]); + this.url.path.push(this.base.path[0]); } this.url.host = this.base.host; } From 1a003e8f4c8fe6d14d329e1ffc63674c3fdb927d Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 30 Sep 2020 13:11:34 -0400 Subject: [PATCH 3/4] Update test and readme pointers --- README.md | 2 +- scripts/get-latest-platform-tests.js | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 86e4ff9..99e3b06 100644 --- a/README.md +++ b/README.md @@ -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"`). diff --git a/scripts/get-latest-platform-tests.js b/scripts/get-latest-platform-tests.js index 9b218d1..1132b4e 100644 --- a/scripts/get-latest-platform-tests.js +++ b/scripts/get-latest-platform-tests.js @@ -24,11 +24,8 @@ 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 urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`; - -const commitHash = "094fcd4dd2b881a7f751f9c1f55534cbe08b151f"; -const urlPrefix = `https://raw.githubusercontent.com/alwinb/wpt/${commitHash}/url/`; +const commitHash = "11a6ab8df5f84d40d8818afe8773dd519e5263e4"; +const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`; const targetDir = path.resolve(__dirname, "..", "test", "web-platform-tests"); From aa358250f91a2df1463f456e1a1633223c4cc85b Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 30 Sep 2020 13:12:16 -0400 Subject: [PATCH 4/4] Tweak newlines to reduce diff --- scripts/get-latest-platform-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/get-latest-platform-tests.js b/scripts/get-latest-platform-tests.js index 1132b4e..55d42f2 100644 --- a/scripts/get-latest-platform-tests.js +++ b/scripts/get-latest-platform-tests.js @@ -25,8 +25,8 @@ process.on("unhandledRejection", err => { // 2. Press "y" on your keyboard to get a permalink // 3. Copy the commit hash const commitHash = "11a6ab8df5f84d40d8818afe8773dd519e5263e4"; -const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`; +const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`; const targetDir = path.resolve(__dirname, "..", "test", "web-platform-tests"); clearDir(targetDir);