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

Append to path and work correctly with or without trailing slash in url #34

Closed
kendaleiv opened this issue Jul 25, 2012 · 4 comments
Closed
Labels

Comments

@kendaleiv
Copy link

new URI().path() + 'test';

can work or not depending if the first part ends with a /. I'd rather not hack the adding of a slash in JavaScript or use any sort of rewriting.

Would it make sense to add an appendPath method or something like that?

@rodneyrehm
Copy link
Member

I was thinking about adding a function pathSegment(index, value). This would split /foo/bar/baz.html into ['foo', 'bar', 'baz.html']. You could retrieve "foo" with pathSegment(0) and overwrite it with pathSegment(0, "bam"). pathSegment("foobar") could append to the path. I'm not sure how to handle filenames in this case, though. I'm open to suggestions.

@kendaleiv
Copy link
Author

Could it simply append it after the filename? I'm not sure what would be the expected behavior, but I'm basically looking for a way to append and I don't have to deal with filenames in this instance.

Is there a common use case for appending something to the path but have it be inserted before a filename anyhow?

I think an append method that goes after everything but before the query string and hash would satisfy my requirement, but might need to call it something other than pathSegment if it appends after a filename?

@rodneyrehm
Copy link
Member

Could it simply append it after the filename? I'm not sure what would be the expected behavior, but I'm basically looking for a way to append and I don't have to deal with filenames in this instance.

Of course it could, this would be the simplest approach.

Is there a common use case for appending something to the path but have it be inserted before a filename anyhow?

no idea. that's why I'm looking for some input.

I think an append method that goes after everything but before the query string and hash would satisfy my requirement, but might need to call it something other than pathSegment if it appends after a filename?

well, pathSegment() or even segment() is just fine, as long as appending is a tertiary operation.

rodneyrehm added a commit that referenced this issue Aug 7, 2012
@rodneyrehm
Copy link
Member

I've added .segment(). It will be included in the next release.

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

No branches or pull requests

2 participants