From 44e6a47d3b93b52b2f602e0d9be910cae48b99a5 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 24 Aug 2020 17:42:45 +0200 Subject: [PATCH] Spec update: make non-special URLs idempotent Follows https://github.com/whatwg/url/pull/505. --- README.md | 2 +- scripts/get-latest-platform-tests.js | 2 +- src/url-state-machine.js | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ddbca62..86e4ff9 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 [975614e](https://github.com/whatwg/url/commit/975614edeee28628298d39af174e9a276366de4f). +whatwg-url is currently up to date with the URL spec up to commit [83adf0c](https://github.com/whatwg/url/commit/83adf0c9ca9a88948e1e5d93374ffded04eec727). 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 8f08bde..cdbad15 100644 --- a/scripts/get-latest-platform-tests.js +++ b/scripts/get-latest-platform-tests.js @@ -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 = "6c74b7e43c9a1f6dc3dc529e427e2ef96152409e"; +const commitHash = "551c9d604fb8b97d3f8c65793bb047d15baddbc2"; const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${commitHash}/url/`; const targetDir = path.resolve(__dirname, "..", "test", "web-platform-tests"); diff --git a/src/url-state-machine.js b/src/url-state-machine.js index 3dc247c..21976d6 100644 --- a/src/url-state-machine.js +++ b/src/url-state-machine.js @@ -1113,8 +1113,11 @@ function serializeURL(url, excludeFragment) { if (url.cannotBeABaseURL) { output += url.path[0]; } else { - for (const string of url.path) { - output += "/" + string; + if (url.host === null && url.path.length > 1 && url.path[0] === "") { + output += "/."; + } + for (const segment of url.path) { + output += "/" + segment; } }