1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
There has to be some hard and fast conventions for dealing with url paths.
the problem:
suppose you write $root/$path
depending on the values of $root and $path, you might end up with:
//path or root/path or root//path or root/ or root//
the first option, //path is REALLY BAD because web browsers think this is
domain name. the others are ugly, but will be understood by the browser.
so, the convention:
ROOT
root variables must either be empty or start with a /. They may not end in a
slash.
PATH
path variables can be empty or in the form "path/to/something". They should end
in a slash if the path is to a directory. it should start with a / if and
only if this path is absolute (in regards to our site root).
SO:
there are two correct ways of specifying a path:
$root$path if the path starts with a /
$path if the path does not start with a /
the function link() should handle this for you.
|