[whatwg] URL decomposition on HTMLAnchorElement interface

Biju bijumaillist at gmail.com
Thu Mar 26 20:01:34 PDT 2009

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

More information about the whatwg mailing list