mrkkrp / modern-uri

Modern library for working with URIs
Other
68 stars 18 forks source link

appending paths to urls #49

Open juhp opened 2 years ago

juhp commented 2 years ago

One thing I am having a hard time seeing is how does one add a relative path to a uri.

For me it would be quite helpful to have a simple combinator like:

url +/+ dir (ie 'https://example.org/pub' +/+ 'some/subdir' == 'https://example.org/pub/some/subdir')

I dunno if the lens module makes this easier - but I generally try to avoid them.

Actually when I use relativeTo it replaces the path from the base URI with that of the relative URI path. Is there any smarter way to handle such changes?

juhp commented 2 years ago

Well I get the feeling this may be a little like asking for "append path" to a http-client Request. I suppose the main difference just being that this is a URI library.

mrkkrp commented 2 years ago

Currently the way to do it is to manipulate the uriPath field either "manually" or with lenses. I imagine it can get a bit annoying if you want to take into account query parameters and fragments... Perhaps a function to do that would be a nice addition to the library.

juhp commented 2 years ago

Thanks

Oh, maybe I just want the Url type from req, which seems to already support what I want AFAICT.