A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).

Difference between revisions of "URL"

From WHATWG Wiki
Jump to navigation Jump to search
(→‎UI: add chrome)
Line 109: Line 109:
* http://www.chromium.org/developers/design-documents/idn-in-google-chrome (also includes summary for other browsers)
* http://www.chromium.org/developers/design-documents/idn-in-google-chrome (also includes summary for other browsers)
* https://wiki.mozilla.org/IDN_Display_Algorithm
* https://wiki.mozilla.org/IDN_Display_Algorithm
* http://www.alvestrand.no/pipermail/idna-update/2011-December/date.html (has lots of background discussion)

=== Notes ===
=== Notes ===

Revision as of 12:10, 26 November 2012

This documents research and notes around URLs for the URL standard.



Variants of the following code (runs in Live DOM Viewer) are useful to test which code points are URL escaped in browsers:

<!DOCTYPE html>
var a = document.createElement("a")

i = 0
cp = 0x100

while ( i < cp ) {
  a.href = "http://x" + String.fromCharCode(i) + "@x/"
  if(a.href.length != "http://x)@x/".length) {


JavaScript libraries

For improving the API we might want to take inspiration from:


Apart from the scheme-types listed below, the URL Standard identifies "relative schemes", used for parsing a URL into a parsed URL.

Purpose-specific schemes

URL schemes are purpose-specific schemes if they only work in one context. These only work for WebSocket:

  • ws
  • wss

Resource schemes

URL schemes are resource schemes if fetching the URL results in either a network error or a resource with associated MIME type (potentially sniffed).

These all can be used by the corresponding protocol directly.
Needs platform-specific interpretation and mapping to a resource on a the local file system.
Needs its resource and MIME type information retrieved from its scheme data/query.
Needs its resource retrieved from its scheme data/query/fragment.
The resource is effectively the result of passing scheme data to a hash table (not sure if case-sensitive or not; definitely no percent decoding). Query and fragment can be used by the resource.

(The same-origin definition should maybe account for about/blob/data. javascript should always be special-cased, the rest is then handled automatically.)

External schemes

Depending on the context, schemes not listed above will either launch an external application or result in a network error. Examples:

  • mailto
  • skype



  • IDNA2003+: IDNA2003 with Unicode updated to the latest version. (So not NFKC from Unicode 3.2., although Python might do that... ) Restrictions on display might be in place.
  • IDNA2008+: IDNA2008 with RFC 5895 section 2 mapping and IDNA2003 domain label separators. Display is restricted to IDNA2008, lookup is unrestricted (everything gets Punycoded).


  • IDNA2003+: Safari, Chrome, Firefox, Internet Explorer
  • IDNA2008+: Opera



  • ToLabels(domain string) -> ASCII-label list (empty label at the end signifies trailing dot) or failure.
  • ToASCII(Unicode-label) -> ASCII-label.
  • ToUnicode(ASCII-label) -> Unicode label.

(For convenience maybe ToASCII and ToUnicode should accept lists too.)


Note that this has potential security implications too, but does not matter for interoperability.