I\'m trying to find a robust method of joining partial url path segments together. Is there a quick way to do this?
I tried the following:
puts URI::
My understanding of URI::join
is that it thinks like a web browser does.
To evaluate it, point your mental web browser to the first parameter, and keep clicking links until you browse to the last parameter.
For example, URI::join('http://example.com/resource/', '/edit', '12?option=test')
, you would browse like this:
/edit
(a file at the root of the site)12?option=test
(a file in the same directory as edit
)If the first link were /edit/
(with a trailing slash), or /edit/foo
, then the next link would be relative to /edit/
rather than /
.
This page possibly explains it better than I can: Why is URI.join so counterintuitive?