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

Closed
kendaleiv opened this Issue Jul 25, 2012 · 4 comments

Projects

None yet

2 participants

@kendaleiv
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
Medialize 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

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
Medialize 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
Medialize member

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

@rodneyrehm rodneyrehm closed this Aug 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment