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

path segment functions #53

Open
dsheets opened this issue Aug 12, 2014 · 7 comments
Open

path segment functions #53

dsheets opened this issue Aug 12, 2014 · 7 comments
Milestone

Comments

@dsheets
Copy link
Member

dsheets commented Aug 12, 2014

There should be interface functions to operate over path segments and provide the same kind of services that are available to query components.

@dsheets dsheets added this to the 2.0 milestone Feb 7, 2015
@Drup
Copy link
Member

Drup commented Apr 6, 2015

That would be useful in ocsigen as well, some kind of segmented_path: string list function.

@dsheets
Copy link
Member Author

dsheets commented Apr 17, 2015

A prime test for this functionality will be the original segment-of-only-%2F of 37771d7. Other segments containing %2F work fine.

@rgrinberg
Copy link
Member

I'm +1 on this. to give an example of the kind of this kind functionality being useful in the real world [1]:

val add_path_to_url :  string list -> string -> string

Would be great to have something like this.

[1] https://github.com/rgrinberg/gapi-ocaml/blob/master/src/gapi/gapiUtils.mli#L19

@dsheets
Copy link
Member Author

dsheets commented May 18, 2015

You can achieve most of that with resolve:

# Uri.(resolve "" (of_string "/foo/bar/") (of_string "baz/quux/"));;
- : Uri.t = /foo/bar/baz/quux
# Uri.(resolve "" (of_string "/foo/bar/") (of_string "/baz/quux"));;
- : Uri.t = /baz/quux
# Uri.(resolve "" (of_string "/foo/bar/") (of_string "../baz/quux"));;
- : Uri.t = /foo/baz/quux
# Uri.(resolve "" (of_string "/foo/bar") (of_string "baz/quux"));;
- : Uri.t = /foo/baz/quux

@rgrinberg
Copy link
Member

It's a decent workaround for sure. But it's hard to imagine a user discovering it on their own and I thought this ticket was about adding helpers for this.

@dsheets
Copy link
Member Author

dsheets commented May 18, 2015

I do think more needs to be done to make users aware of the power of resolve.

This issue is about exposing the structure of the path component directly as it must be represented internally. Right now, paths clearly have structure but are opaque at the API level. The library should be able to help users more when they want to route HTTP requests or walk directory trees.

@mseri
Copy link
Contributor

mseri commented May 20, 2021

+1 for this, would be really useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants