Forum: Ruby URI#path, windows, and file urls

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Berger, Daniel (Guest)
on 2006-04-17 22:37
(Received via mailing list)
Hi all,

Ruby 1.8.4
Windows XP

Is this correct?

require 'uri'
URI.parse("file:///C:/foo/bar").path # => "/C:/foo/bar"

The leading slash seems wrong to me, but then I'm not familiar with the
RFC's that cover such things.

Any insight appreciated.

Thanks,

Dan
Bd0203dc8478deb969d72f52e741bd4f?d=identicon&s=25 Daniel Baird (Guest)
on 2006-04-18 02:18
(Received via mailing list)
I think the trick is that the file:// is the protocol, and the next / is
saying "absolute local path".

If you had no third slash.. file://myserver/share/dir will look for a
host
"myserver".  I guess if there wasn't a / before the c: then
file://c:/dirwould be looking for a host named "c:".

Of course there are more relaxed implementations than the RFC provides..


Cheers

;Daniel


On 18/04/06, Berger, Daniel <Daniel.Berger@qwest.com> wrote:
>
> The leading slash seems wrong to me, but then I'm not familiar with the
> RFC's that cover such things.
>
> Any insight appreciated.
>
> Thanks,
>
> Dan
>
>


--
Daniel Baird
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
Things
That Suck)
[[My webhost uptime is ~ 92%.. if no answer pls call again later!]]
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-04-18 04:23
(Received via mailing list)
On Apr 17, 2006, at 4:34 PM, Berger, Daniel wrote:

> The leading slash seems wrong to me, but then I'm not familiar with
> the
> RFC's that cover such things.
>
> Any insight appreciated.
>
> Thanks,
>
> Dan

I think this is a case of Windows having multiple roots (A: , B: ,
C:, etc.) and URI obviously can't know a) I'm running on windows so
b) C: is a root and not a directory named "C:". And it can't just
guess because conceivably C: might be a directory on windows in some
cases
This topic is locked and can not be replied to.