Skip to content
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

Merged
merged 3 commits into from May 12, 2023
Merged

Conversation

armanbilge
Copy link
Member

First two commits are just some tidying. The fix is in 2096b29.

@armanbilge
Copy link
Member Author

Btw, this case isn't included in the examples in the spec. Any insight?

https://www.rfc-editor.org/rfc/rfc3986#section-5.4.1

@kubukoz
Copy link
Contributor

kubukoz commented Apr 14, 2023

now that is a scary looking diff. Compared to what it really is 😬

Copy link
Member

@rossabaker rossabaker left a 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.

@armanbilge armanbilge changed the title Fix resolution of root / URIs Fix resolving of root / URIs Apr 15, 2023
@@ -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 =>
Copy link
Member

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?

Copy link
Member Author

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? 😵

Copy link
Member

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 /.

@armanbilge armanbilge merged commit b7d0a62 into series/0.23 May 12, 2023
16 checks passed
@armanbilge armanbilge deleted the pr/fix-uri-resolve-root branch May 12, 2023 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:core series/0.23 PRs targeting 0.23.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants