W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2009

[whatwg] URL decomposition on HTMLAnchorElement interface

From: Biju <bijumaillist@gmail.com>
Date: Thu, 26 Mar 2009 23:01:34 -0400
Message-ID: <4a27dd80903262001y32d94941vc58d1be1e36474f3@mail.gmail.com>
On Thu, Mar 26, 2009 at 5:26 PM, Kartikaya Gupta
> This behavior seems rather inconsistent and possibly buggy.

At first look I also thought it is inconsistent
But later I found Firefox is very consistent.
I think reason why it happening like that is because Firefox clean up
URL by removing extra slash before host name
and adding a slash after host name and also convert host name to lowercase.

Try this

var a = document.createElement('a');
a.setAttribute('href', 'http:/Example.org:123/foo?bar#baz');   //Case 1
a.setAttribute('href', 'http:example.org:123/foo?bar#baz');    //Case 2
a.setAttribute('href', 'http:///example.org:123/foo?bar#baz');    //Case 3
a.setAttribute('href', 'http://///example.org:123/foo?bar#baz');    //Case 4

Firefox clean up the URL
and all shows "http://example.org:123/foo?bar#baz"

So now when you set host as null, I ASSUME following is happening


Firefox do this same for protocols http, https, ftp for others it wont
allow hostname change.

a.hash = null;
a.search = null;
are allowed for http, https, ftp, file and jar
(may be for data: also, I have not tested it)

You can use a null string instead of null.
And I know host name can not be set to space or a string containing space.
But it is allowing invalid characters like !$%^&*( etc.
Get confused when it find @#? as hostname

Now question is do we need to allow to set host to a null or ""?

PS: Jar protocol example
Received on Thursday, 26 March 2009 20:01:34 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:48 UTC