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

Dubious .relativeTo behaviour #75

Closed
djcsdy opened this Issue Apr 15, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@djcsdy
Contributor

djcsdy commented Apr 15, 2013

URI("http://example.org/foo/bar/bat").
    relativeTo("http://example.org/").
    toString()
// => "http://example.org/foo/bar/bat"

I think this should return "foo/bar/bat" (preferably) or "./foo/bar/bat" (if you must, but see below).

URI("http://example.org/foo/bar/bat").
    relativeTo("http://example.org/foo").
    toString()
// => "../bar/bat"

Since we’re resolving relative to a URL whose path doesn’t end with a slash, foo shouldn’t be treated as a directory, so I think this should return the same result as for the first example above. Even if we do (incorrectly) treat foo as a directory, this result doesn’t make any sense.

URI("http://example.com/foo/bar/bat").
    relativeTo("http://example.org/foo/").
    toString()
// => "./bar/bat"

I think this should return "//example.com/foo/bar/bat" (note that example.com and example.org are different; the only URI component in common is the http scheme).

URI("http://example.org/foo/bar/bat").
    relativeTo("http://example.org/foo/").
    toString()
// => "./bar/bat"

This is correct but the ./ is redundant so the resulting URL is not normalized. I feel like relativeTo would be more useful if it did not insert redundant dot segments. For instance, I want to be able to relativize a URL with respect to the root URL of my application, and then iterate through segment() to route a request to the correct controller. The current implementation obliges me to do extra work to remove the dot segment :(.

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