scala-uri icon indicating copy to clipboard operation
scala-uri copied to clipboard

Uri.relativize

Open bblfish opened this issue 1 year ago • 2 comments

Description The equivalent of java.net.URI.relativize(uri: URI)

It should work with relative URLs applied to relative URLs as well as absolute Urls applied to absolute ones.

Url("https://bblfish.net/people/")
     .relativize("https://bblfish.net/people/henry/card#me") 
     == Url("henry/card#me")

There could also be a slightly more advanced version that could follow through parent hierarchies, perhaps something like

Url("https://bblfish.net/people/henry/")
     .relativize2("https://bblfish.net/people/tini/pix/cat.jpg") 
     == Url("../henry/pix/cat.jpg")

bblfish avatar Sep 18 '22 17:09 bblfish

Note: I have a PR that builds on lemon labs URI and test suites here. (Btw. Java URL normalization don't replace default ports I noticed...)

https://github.com/banana-rdf/banana-rdf/pull/379/files#diff-9ab8031fc5aa2672acd07b807d370de6760feeef2b23864f63e10c8de8365c40

bblfish avatar Sep 21 '22 06:09 bblfish

Oops, I don't know why I closed this...

bblfish avatar Sep 21 '22 12:09 bblfish