lemonlabsuk / scala-uri

Simple scala library for building and parsing URIs
Other
305 stars 34 forks source link

Uri.relativize #466

Open bblfish opened 2 years ago

bblfish commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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