Re: $url->path

Gisle Aas (aas@bergen.sn.no)
Thu, 08 Feb 1996 11:47:02 +0100


In message <9602071141.aa05023@paris.ics.uci.edu>, "Roy T. Fielding" writes:
> > Can anybody explain the rationale behind stating that "/" is *NOT*
> > part of the path?
> 
> It is a long and painfull story, but the gist of it is that
> 
>      http://site
> and  http://site/
> 
> are equivalent because the "/" is a separator and not part of the path.
> Naturally, this leads to all sorts of confusion because it is part of
> the path during an HTTP request.
> 
> This is what happens when standards are written without regard for
> how the standard is used -- what it should have said is that the
> slash is part of the path and that the path defaults to "/" when
> nothing is present.  Unfortunately, the URI WG did not have a
> sufficient number of HTTP implementors in attendance.

I think I will implement this understanding of things in the next
release and then provide some backwards compatibility flags that can
be set for code that relies on the old behaviour.

Things should then (by default) behave like this:

$u = new URI::URL 'file:/';
$p = $u->path;   # $p is now "/"

$u->path("");
$p = $u->path;   # $p is now "/"

# I.e. all of these will be do the same thing
$u->path(undef);
$u->path("");
$u->path("/");
# This is different from the normal Unix semantics where the empty
# string is treated as '.'

$u->path("foo/bar"); # path is now relative
$u->path($u->path);  # Does never change anything

# The behaviour of then path_components method will then become
$u->path("");
@a = $u->path_components;  # @a = ("")
$u->path("/");
@a = $u->path_components;  # @a = ("")
$u->path("/a");
@a = $u->path_components;  # @a = ("", "a")
$u->path("/a/");
@a = $u->path_components;  # @a = ("", "a", "")

# and this does not change anything
$u->path_components($u->path_components)

# except loose the distinction between '.' and '%2e' :-(.

--Gisle