New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix resolving of root / URIs #7064
Conversation
Btw, this case isn't included in the examples in the spec. Any insight? |
now that is a scary looking diff. Compared to what it really is 😬 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No insight on the missing case in the RFC, but it's intuitive and matches java.net.URI
and Python's urllib.parse.urljoin
. The former implements an old RFC and the latter is another language, but at least it's not counterevidence.
@@ -929,8 +929,10 @@ object Uri extends UriPlatform { | |||
val target = (base, reference) match { | |||
case (_, Uri(Some(_), _, _, _, _)) => reference | |||
case (Uri(s, _, _, _, _), Uri(_, a @ Some(_), p, q, f)) => Uri(s, a, p, q, f) | |||
case (Uri(s, a, p, q, _), Uri(_, _, pa, Query.empty, f)) if pa.isEmpty => Uri(s, a, p, q, f) | |||
case (Uri(s, a, p, _, _), Uri(_, _, pa, q, f)) if pa.isEmpty => Uri(s, a, p, q, f) | |||
case (Uri(s, a, p, q, _), Uri(_, _, pa, Query.empty, f)) if pa.isEmpty && !pa.absolute => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a skippable minor grumpy nitpick.: does pa.isEmpty && !pa.absolute
merely correspond to pa == Path.empty
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's a good question. It also opens the question that should pa.isEmpty
be equivalent to pa == Path.empty
? Is /
empty or not? 😵
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's interesting, maybe, it's kinda side effect that Path.empty
equals /
.
First two commits are just some tidying. The fix is in 2096b29.