This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23461 - Strip leading slashes?
Summary: Strip leading slashes?
Status: RESOLVED WORKSFORME
Alias: None
Product: WHATWG
Classification: Unclassified
Component: URL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Anne
QA Contact: sideshowbarker+urlspec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-08 16:17 UTC by Erik Arvidsson
Modified: 2014-01-13 18:23 UTC (History)
2 users (show)

See Also:


Attachments

Description Erik Arvidsson 2013-10-08 16:17:12 UTC
Both WebKit/Blink and Gecko strip leading slashes when setting hostname. IE throws.

a = document.createElement('a');
a.href = 'http://abc.de:8080/path/name?search#hash'
a.hostname = '///xyz';
assert(a.href === 'http://xyz:8080/path/name?search#hash')

I'm also fine throwing in cases like these but we should specify what the intended behavior is.
Comment 1 Anne 2013-10-15 12:32:49 UTC
So you parse using http://url.spec.whatwg.org/#hostname-state as override state. It will lead to "host" being the empty sequence which will lead to the host parser returning failure which means the parse operation will return failure. Which means host remains unchanged.
Comment 2 Anne 2013-10-15 12:35:06 UTC
Note that ignoring invalid values is consistent with eg:

a.hostname = "a a"
Comment 3 Erik Arvidsson 2013-10-15 14:22:37 UTC
In cases like these. Are we trying to spec what browsers do or what we want them to do?

If we are making changes I think I would prefer us to follow IE in these cases and throw instead of silently ignoring.
Comment 4 Anne 2014-01-11 16:53:52 UTC
I'm not sure that specifying what IE does make sense. E.g. if I try

  a = document.createElement("a")
  a.href = "http://example"
  a.hostname = "a:a"

IE does not throw. But if I then read a.hostname it throws. Do we really want to define that? For most other cases we silently ignore errors. Starting to throw could cause more breakage in sites. Apple is typically extremely hesitant to switch from non-throwing to throwing as well.
Comment 5 Anne 2014-01-13 18:23:06 UTC
Ignore was fine in bug 23474 too.