- From: Anne van Kesteren <notifications@github.com>
- Date: Sat, 21 Jan 2017 02:02:15 -0800
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/212/274252010@github.com>
With these changes I get passing tests again: ```diff diff --git a/lib/URL-impl.js b/lib/URL-impl.js index 9e7d67c..0a394a3 100644 --- a/lib/URL-impl.js +++ b/lib/URL-impl.js @@ -136,6 +136,10 @@ exports.implementation = class URLImpl { return this._url.path[0]; } + if (this._url.path.length === 0) { + return ""; + } + return "/" + this._url.path.join("/"); } diff --git a/src/url-state-machine.js b/src/url-state-machine.js index 4534bd6..5e23a24 100644 --- a/src/url-state-machine.js +++ b/src/url-state-machine.js @@ -680,11 +680,13 @@ URLStateMachine.prototype["parse relative"] = function parseRelative(c) { }; URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) { - if (c === p("/") || (isSpecial(this.url) && c === p("\\"))) { + if (isSpecial(this.url) && (c === p("/") || c === p("\\"))) { if (c === p("\\")) { this.parseError = true; } this.state = "special authority ignore slashes"; + } else if(c === p("/")) { + this.state = "authority"; } else { this.url.username = this.base.username; this.url.password = this.base.password; @@ -930,12 +932,27 @@ URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) { }; URLStateMachine.prototype["parse path start"] = function parsePathStart(c) { - if (isSpecial(this.url) && c === p("\\")) { - this.parseError = true; - } - this.state = "path"; - if (c !== p("/") && !(isSpecial(this.url) && c === p("\\"))) { - --this.pointer; + if (!isSpecial(this.url)) { + if (c === p("?")) { + this.url.query = ""; + this.state = "query"; + } else if (c === p("#")) { + this.url.fragment = ""; + this.state = "fragment"; + } else if (!isNaN(c)) { + if (c !== p("/")) { + --this.pointer; + } + this.state = "path"; + } + } else { + if (c !== p("/") && c !== p("\\")) { + --this.pointer; + } + if(c === p("\\")) { + this.parseError = true; + } + this.state = "path"; } return true; @@ -1096,7 +1113,7 @@ function serializeURL(url, excludeFragment) { if (url.cannotBeABaseURL) { output += url.path[0]; - } else { + } else if (url.path.length !== 0) { output += "/" + url.path.join("/"); } ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/url/issues/212#issuecomment-274252010
Received on Saturday, 21 January 2017 10:02:49 UTC