Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: URI.join inconsistency
Eric Hodel
10/1/2007 8:55:00 PM
On Oct 1, 2007, at 03:02 , Gareth Adams wrote:
> I just got stung by rather annoying feature of URI.join:
>
> irb(main):001:0> URI.join('
http://www.example.com/some...
,
> 'else').to_s
> => "
http://www.example.com/...
>
> Note that this completely ignores the 'something' in the original
> URI. I had assumed that it joined in a similar way to File.join:
>
> irb(main):002:0> File.join('/something', 'else').to_s
> => "/something/else"
>
> I notice that adding a slash works as expected, but why is there a
> difference?
URIs and paths are not the same, "
http://example.com/somet...
and
"
http://example.com/someth...
are allowed to return different
content. URI.join works off the directory, "/" in your case, rather
than assuming that "/something" is a directory, which may be incorrect.
(My annoyance with this method is that the first argument cannot be a
URI::Generic.)
--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars
1 Answer
mortee
10/1/2007 9:09:00 PM
0
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: URI.join inconsistency
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password