Zack
Zack

Reputation: 1703

HTML - HREF technical standard for back-referencing directories

This may be completely irrelevant, but maybe you've noticed that:

<a href="./some-file.html">Some File</a>

And:

<a href="some-file.html">Some File</a>

both instruct the browser agent to go to the same URL. The question is, which, if any, is better, and why? Maybe it is merely preference, but I found it worth clarifying...

NOTE: and by "better", I mean, less error-prone with regard to cross-browser compatibility.

Upvotes: 1

Views: 72

Answers (1)

Intermernet
Intermernet

Reputation: 19388

From "Uniform Resource Identifiers (URI): Generic Syntax" (Section 4, URI References)

"Within a relative-path reference, the complete path segments "." and ".." have special meanings: "the current hierarchy level" and "the level above this hierarchy level", respectively. Although this is very similar to their use within Unix-based filesystems to indicate directory levels, these path components are only considered special when resolving a relative-path reference to its absolute form"

From the same document (Section 5.2 Resolving Relative References to Absolute Form, 6, c):

"The relative path needs to be merged with the base URI's path." ... "All occurrences of "./", where "." is a complete path segment, are removed from the buffer string."

So, to the URI parser, "./" and "" are equal.

EDIT: The RFC quoted above has been obsoleted by http://www.rfc-editor.org/rfc/rfc3986.txt . The relevant section of that (as far as I can determine) is Section 5.2.4. Remove Dot Segments .

Upvotes: 1

Related Questions