Parsing relative URLs

Discussion in 'HTML' started by carlbernardi@gmail.com, Jun 1, 2008.

  1. Guest

    Hi,

    While parsing relative URL segments "../" to hierarchical segments of
    the absolute URL , I notice that the <a> tag and the <link> tag do
    this differently. Take the following absolute and relative URLs:

    absolute URL: http://www.a.com/a/b
    relative URL: ../../b/c.css

    The <a> tag resolves this to:

    http://www.a.com/b/c.css

    However the <link> tag resolves this to:

    http://www.a.com/a/b/c.css



    It appears that all other forms of resolving URLs are equal between
    both tags however, I have been trying to find the RFC specification on
    this but have had no luck. This document http://www.ietf.org/rfc/rfc2396.txt
    does not contain any information regarding the <link> tag.

    Is anyone here familiar with this or know where I could obtain more
    information.

    Thanks,


    Bandito



    http://www.gaihosa.com
    , Jun 1, 2008
    #1
    1. Advertising

  2. Lars Eighner Guest

    In our last episode,
    <>, the
    lovely and talented broadcast on alt.html:

    > Hi,


    > While parsing relative URL segments "../" to hierarchical segments of
    > the absolute URL , I notice that the <a> tag and the <link> tag do
    > this differently. Take the following absolute and relative URLs:


    > absolute URL: http://www.a.com/a/b
    > relative URL: ../../b/c.css


    But this is nonsense. It is looking for the parent of the root,
    but of course there cannot be one.

    > The <a> tag resolves this to:


    > http://www.a.com/b/c.css


    > However the <link> tag resolves this to:


    > http://www.a.com/a/b/c.css


    In other words, some browser or another, presented with an absurdity, has
    inconsistent error handling. Well, obviously, other than writing to the
    authors of the browser about that, the solution would be not to write
    relative URLs that are absurd.

    > It appears that all other forms of resolving URLs are equal between
    > both tags however, I have been trying to find the RFC specification on
    > this but have had no luck. This document http://www.ietf.org/rfc/rfc2396.txt
    > does not contain any information regarding the <link> tag.


    I don't think you will find many specs that deal with error recovery. There
    are so many possible errors that the point of defining the right way would
    be lost in all the stuff about what to do when people do things the wrong
    way.

    > Is anyone here familiar with this or know where I could obtain more
    > information.


    -
    Lars Eighner <http://larseighner.com/>
    Countdown: 232 days to go.
    Lars Eighner, Jun 1, 2008
    #2
    1. Advertising

  3. wrote:
    > Hi,
    >
    > While parsing relative URL segments "../" to hierarchical segments of
    > the absolute URL , I notice that the <a> tag and the <link> tag do
    > this differently. Take the following absolute and relative URLs:
    >
    > absolute URL: http://www.a.com/a/b
    > relative URL: ../../b/c.css
    >
    > The <a> tag resolves this to:
    >
    > http://www.a.com/b/c.css


    Not in my test.

    >
    > However the <link> tag resolves this to:
    >
    > http://www.a.com/a/b/c.css
    >


    File /a/b/c.css:

    body { color: red; }

    File /b/c.css:

    body { color: green; }

    File /a/b/x.html:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Relative URLs: Link vs. A</title>
    <link rel="stylesheet" type="text/css" href="../../b/c.css">
    </head>

    <body>
    <p>If the LINK tag resolves the relative URL
    to http://localhost/b/c.css, this will be green.</p>
    <p>If it resolves it to http://localhost/a/b/c.css,
    this will be red.</p>
    <p><a href="../../b/c.css">Click here</a></p>
    </body>
    </html>

    In both Internet Explorer and Firefox, the page's text appears in green,
    and the link leads to the file that reads

    body { color: green; }

    In other words, both the LINK and the A tags point--correctly--to
    /b/c.css. Therefore, I think you made a mistake somewhere in your
    experiment.
    Harlan Messinger, Jun 1, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. abcd

    https and relative urls

    abcd, Aug 2, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    434
  2. Kaidi
    Replies:
    5
    Views:
    454
    Andrew Thompson
    Jan 4, 2004
  3. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    731
    Sriram Srivatsan
    Aug 12, 2008
  4. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,116
    Adam Monsen
    Feb 8, 2009
  5. Steve T.

    dynamic URLS convert to static URLS for search engines

    Steve T., Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    272
    Steve T.
    Mar 4, 2004
Loading...

Share This Page