From 078a0e9aaccee969c4869d4c3d7d0f7c6f337257 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 23 Dec 2014 10:02:48 +0100 Subject: [PATCH] Organize the common html.spec.whatwg.org urls together. Also generate url.html again. Fixes PR #15. --- url.bs | 16 +- url.html | 5703 +++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 3932 insertions(+), 1787 deletions(-) diff --git a/url.bs b/url.bs index 71bc707..c01c471 100644 --- a/url.bs +++ b/url.bs @@ -2930,13 +2930,15 @@ urlPrefix: https://encoding.spec.whatwg.org/; type: dfn text: utf-8 decode without bom text: utf-8 encode text: utf-8 decoder -urlPrefix: https://html.spec.whatwg.org/multipage/comms.html; type: interface; - text: EventSource - text: HashChangeEvent -urlPrefix: https://html.spec.whatwg.org/multipage/browsers.html; type: dfn; - text: origin - text: unicode serialization of an origin -urlPrefix: https://html.spec.whatwg.org/multipage/infrastructure.html; type: dfn; text: structured clone +urlPrefix: https://html.spec.whatwg.org/multipage/ + urlPrefix: comms.html; type: interface; + text: EventSource + text: HashChangeEvent + urlPrefix: browsers.html; type: dfn; + text: origin + text: unicode serialization of an origin + urlPrefix: infrastructure.html; type: dfn; + text: structured clone urlPrefix: http://heycam.github.io/webidl/#dfn-; type: dfn; text: throw text: value pairs to iterate over diff --git a/url.html b/url.html index a912c56..98cd890 100644 --- a/url.html +++ b/url.html @@ -1,9 +1,22 @@ - - URL Standard - - - - + - -
-

-

-

URL

-

Living Standard — Last Updated -

-
Version History:
https://github.com/whatwg/url/commits @urlstandard
Participate:
file a bug (open bugs)
whatwg@whatwg.org (archives)
IRC: #whatwg on Freenode
-
-
-

Abstract

-

The URL Standard defines URLs, domains, IP addresses, the application/x-www-form-urlencoded format, and their API.

+ + +
+ +

+

+ +

URL

+ +

Living Standard — Last Updated +

+ +
+
+
Version History:
+
https://github.com/whatwg/url/commits @urlstandard
+
Participate:
+
file a bug (open bugs)
+
whatwg@whatwg.org (archives)
+
IRC: #whatwg on Freenode
+
+
+ +
-
+ -

Table of Contents

-
-
+

Abstract

+ -

Goals

+
+

The URL Standard defines URLs, domains, IP addresses, the application/x-www-form-urlencoded format, and their API.

-

The URL standard takes the following approach towards making URLs fully interoperable: +

+ + +
+ + + +

Table of Contents

+ + +
+
+ + +
+ + + +

Goals

+ + +

The URL standard takes the following approach towards making URLs fully interoperable: -

    -
  • Align RFC 3986 and RFC 3987 with contemporary implementations and +

    +
      + +
    • +

      Align RFC 3986 and RFC 3987 with contemporary implementations and obsolete them in the process. (E.g. spaces, other "illegal" code points, query encoding, equality, canonicalization, are all concepts not entirely shared, or defined.) URL parsing needs to become as solid as HTML parsing. - [RFC3986] - [RFC3987] + [RFC3986] + [RFC3987] -

    • Standardize on the term URL. URI and IRI are just confusing. In +

      +
    • +
    • +

      Standardize on the term URL. URI and IRI are just confusing. In practice a single algorithm is used for both so keeping them distinct is not helping anyone. URL also easily wins the search result popularity contest. -

    • Supplanting Origin of a URI [sic]. - [RFC6454] +

      +
    • +
    • +

      Supplanting Origin of a URI [sic]. + [RFC6454] -

    • Define URL’s existing JavaScript API in full detail and add - enhancements to make it easier to work with. Add a new URL +

      +
    • +
    • +

      Define URL’s existing JavaScript API in full detail and add + enhancements to make it easier to work with. Add a new URL object as well for URL manipulation without usage of HTML elements. (Useful for JavaScript worker environments.) -

    +

    +
-

As the editors learn more about the subject matter the goals + +

As the editors learn more about the subject matter the goals might increase in scope somewhat. -

1. Terminology

+

+

1. Terminology

+ -

Some terms used in this specification are defined in the +

Some terms used in this specification are defined in the DOM, Encoding, IDNA, and Web IDL Standards. -[DOM] -[ENCODING] -[IDNA] -[WEBIDL] +[DOM] +[ENCODING] +[IDNA] +[WEBIDL] -

The ASCII digits are code points in the range U+0030 to U+0039. +

+

The ASCII digits are code points in the range U+0030 to U+0039. -

The ASCII hex digits are ASCII digits or are +

+

The ASCII hex digits are ASCII digits or are code points in the range U+0041 to U+0046 or in the range U+0061 to U+0066. -

The ASCII alpha are code points in the range U+0041 to U+005A +

+

The ASCII alpha are code points in the range U+0041 to U+005A or in the range U+0061 to U+007A. -

The ASCII alphanumeric are ASCII digits or -ASCII alpha. +

+

The ASCII alphanumeric are ASCII digits or +ASCII alpha. + +

+

1.1. Parsers

-

1.1. Parsers

-

The EOF code point is a conceptual code point that signifies the end of a +

The EOF code point is a conceptual code point that signifies the end of a string or code point stream. -

A parse error indicates a non-fatal mismatch between input and requirements. -User agents are encouraged to expose parse errors +

+

A parse error indicates a non-fatal mismatch between input and requirements. +User agents are encouraged to expose parse errors somehow. -

Within a parser algorithm that uses a pointer variable, c +

+

Within a parser algorithm that uses a pointer variable, c references the code point the pointer variable points to. -

Within a string-based parser algorithm that uses a pointer variable, -remaining references the substring after pointer in the string +

+

Within a string-based parser algorithm that uses a pointer variable, +remaining references the substring after pointer in the string being processed. -

If "mailto:username@example" is a string being +

+

If "mailto:username@example" is a string being processed and pointer points to "@", -c is "@" and remaining is +c is "@" and remaining is "example". -

2. Percent-encoded bytes

+

+

2. Percent-encoded bytes

+ -

A percent-encoded byte is "%", followed by -two ASCII hex digits. Sequences of -percent-encoded bytes, after +

A percent-encoded byte is "%", followed by +two ASCII hex digits. Sequences of +percent-encoded bytes, after conversion to bytes, should not cause a -utf-8 decoder to run into any -errors. +utf-8 decoder to run into any +errors. -

To percent encode a byte into a -percent-encoded byte, return a string consisting of +

+

To percent encode a byte into a +percent-encoded byte, return a string consisting of "%", followed by a double-digit, uppercase, hexadecimal representation of byte. -

To percent decode a byte sequence input, run these steps: +

+

To percent decode a byte sequence input, run these steps: -

Using anything but a utf-8 decoder +

+

Using anything but a utf-8 decoder when the input contains bytes outside the range 0x00 to 0x7F might be insecure and is not recommended. -

    -
  1. Let output be an empty byte sequence. +

    +
      + +
    1. +

      Let output be an empty byte sequence. -

    2. -

      For each byte byte in input, run these steps: +

      +
    3. +
    4. + +

      For each byte byte in input, run these steps: -

        -
      1. If byte is not `%`, append +

        +
          + +
        1. +

          If byte is not `%`, append byte to output. -

        2. Otherwise, if byte is `%` and the next two +

          +
        3. +
        4. +

          Otherwise, if byte is `%` and the next two bytes after byte in input are not in the ranges 0x30 to 0x39, 0x41 to 0x46, and 0x61 to 0x66, append byte to output. -

        5. -

          Otherwise, run these substeps: +

          +
        6. +
        7. + +

          Otherwise, run these substeps: -

            -
          1. Let bytePoint be the two bytes after byte in +

            +
              + +
            1. +

              Let bytePoint be the two bytes after byte in input, - decoded, and + decoded, and then interpreted as hexadecimal number. -

            2. Append a byte whose value is bytePoint to +

              +
            3. +
            4. +

              Append a byte whose value is bytePoint to output. -

            5. Skip the next two bytes in input. -

            -
          +

          +
        8. +
        9. +

          Skip the next two bytes in input. +

          +
        10. +
        + + +
      2. +
      + + + +
    5. +
    6. +

      Return output. +

      +
    -
  2. Return output. -

-

-

The simple encode set are all code points less than +

+ +

The simple encode set are all code points less than U+0020 (i.e. excluding U+0020) and all code points greater than U+007E. -

The default encode set is the -simple encode set and code points U+0020, +

+

The default encode set is the +simple encode set and code points U+0020, '"', "#", "<", -">", +">", "?", and "`". -

The password encode set is the -default encode set and code points +

+

The password encode set is the +default encode set and code points "/", "@", and "\". -

The username encode set is the -password encode set and code point +

+

The username encode set is the +password encode set and code point ":". -

To utf-8 percent encode a code point, using +

+

To utf-8 percent encode a code point, using an encode set, run these steps: -

    -
  1. If code point is not in +

    +
      + +
    1. +

      If code point is not in encode set, return code point. -

    2. Let bytes be the result of running - utf-8 encode on +

      +
    3. +
    4. +

      Let bytes be the result of running + utf-8 encode on code point. -

    5. Percent encode each byte in bytes, and +

      +
    6. +
    7. +

      Percent encode each byte in bytes, and then return them concatenated, in the same order. -

    +

    +
+ -

3. Hosts (domains and IP addresses)

+

3. Hosts (domains and IP addresses)

-

A host is a network address in the form of a -domain or an -IPv6 address. -

A domain identifies a realm within a network. +

A host is a network address in the form of a +domain or an +IPv6 address. + +

+

A domain identifies a realm within a network. -

An IPv6 address is a 128-bit identifier and +

+

An IPv6 address is a 128-bit identifier and for the purposes of this specification represented as an ordered list of -eight 16-bit pieces. -[RFC4291] +eight 16-bit pieces. +[RFC4291] + +

+

3.1. IDNA

-

3.1. IDNA

-

The domain to ASCII given a -domain domain, runs these steps: +

The domain to ASCII given a +domain domain, runs these steps: -

    -
  1. Let result be the result of running - Unicode ToASCII with +

    +
      + +
    1. +

      Let result be the result of running + Unicode ToASCII with domain_name set to domain, UseSTD3ASCIIRules set to false, processing_option set to Transitional_Processing, and VerifyDnsLength set to false. -

    2. If result is a failure value, return failure. +

      +
    3. +
    4. +

      If result is a failure value, return failure. + +

      +
    5. +
    6. +

      Return result. +

      +
    -
  2. Return result. -

-

The domain to Unicode given a -domain domain, runs these steps: +

The domain to Unicode given a +domain domain, runs these steps: -

    -
  1. Let result be the result of running - Unicode ToUnicode with +

    +
      + +
    1. +

      Let result be the result of running + Unicode ToUnicode with domain_name set to domain, UseSTD3ASCIIRules set to false. -

    2. -

      Return result, ignoring any returned errors. +

      +
    3. +
    4. + +

      Return result, ignoring any returned errors. + +

      +

      User agents are encouraged to report errors through a developer console. +

      +
    + -

    User agents are encouraged to report errors through a developer console. -

+

3.2. Host writing

-

3.2. Host writing

-

A host must be either a -domain or "[", followed -by an IPv6 address, followed by +

A host must be either a +domain or "[", followed +by an IPv6 address, followed by "]". -

A domain is a valid domain if these steps return success: +

+

A domain is a valid domain if these steps return success: -

    -
  1. Let result be the result of running - Unicode ToASCII with +

    +
      + +
    1. +

      Let result be the result of running + Unicode ToASCII with domain_name set to domain, UseSTD3ASCIIRules set to true, processing_option set to Nontransitional_Processing, and VerifyDnsLength set to true. -

    2. If result is a failure value, return failure. +

      +
    3. +
    4. +

      If result is a failure value, return failure. -

    5. Set result to the result of running - Unicode ToUnicode with +

      +
    6. +
    7. +

      Set result to the result of running + Unicode ToUnicode with domain_name set to result, UseSTD3ASCIIRules set to true. -

    8. If result contains any errors, return failure. +

      +
    9. +
    10. +

      If result contains any errors, return failure. + +

      +
    11. +
    12. +

      Return success. +

      +
    -
  2. Return success. -

-

Ideally we define this in terms of a sequence of code points that make up a -valid domain rather than through a whack-a-mole: +

Ideally we define this in terms of a sequence of code points that make up a +valid domain rather than through a whack-a-mole: bug 25334. -

A domain must be a string that is a -valid domain. +

+

A domain must be a string that is a +valid domain. -

An IPv6 address is defined in the -"Text Representation of Addresses" chapter of IP Version 6 Addressing Architecture. -[RFC4291]

+

An IPv6 address is defined in the +"Text Representation of Addresses" chapter of IP Version 6 Addressing Architecture. +[RFC4291] +

+ + +

3.3. Host parsing

-

3.3. Host parsing

-

The host parser takes a string +

The host parser takes a string input and optionally a Unicode flag, and then runs these steps: -

    -
  1. If input is the empty string, return failure. +

    +
      + +
    1. +

      If input is the empty string, return failure.

      + -
    2. -

      If input starts with "[", run these + +

    3. +
    4. + +

      If input starts with "[", run these substeps: -

        -
      1. If input does not end with - "]", parse error, return failure. - -

      2. Return the result of - IPv6 parsing input +

        +
          + +
        1. +

          If input does not end with + "]", parse error, return failure. + +

          +
        2. +
        3. +

          Return the result of + IPv6 parsing input with its leading "[" and trailing "]" removed. -

        +

        +
      3. +
      + -
    5. Let domain be the result of - utf-8 decode without BOM on the - percent decoding of - utf-8 encode on input. + +

    6. +
    7. +

      Let domain be the result of + utf-8 decode without BOM on the + percent decoding of + utf-8 encode on input. -

    8. Let asciiDomain be the result of running - domain to ASCII on domain. +

      +
    9. +
    10. +

      Let asciiDomain be the result of running + domain to ASCII on domain. -

    11. If asciiDomain is failure, return failure. +

      +
    12. +
    13. +

      If asciiDomain is failure, return failure. -

    14. -

      If asciiDomain contains one of +

      +
    15. +
    16. + +

      If asciiDomain contains one of U+0000, U+0009, U+000A, @@ -362,455 +617,738 @@

      3.3 "]", return failure. -
    17. Return asciiDomain if the Unicode flag is unset, - and the result of running domain to Unicode +

      +
    18. +
    19. +

      Return asciiDomain if the Unicode flag is unset, + and the result of running domain to Unicode on asciiDomain otherwise. -

    +

    +
+ -

The IPv6 parser takes a string +

The IPv6 parser takes a string input and then runs these steps: -

    -
  1. Let address be a new - IPv6 address with its - 16-bit pieces initialized to 0. +

    +
      + +
    1. +

      Let address be a new + IPv6 address with its + 16-bit pieces initialized to 0. -

    2. Let piece pointer be a pointer into +

      +
    3. +
    4. +

      Let piece pointer be a pointer into address’s - 16-bit pieces, initially zero - (pointing to the first 16-bit piece), + 16-bit pieces, initially zero + (pointing to the first 16-bit piece), and let piece be the - 16-bit piece it points to. + 16-bit piece it points to. -

    5. Let compress pointer be another pointer into - address’s 16-bit pieces, initially +

      +
    6. +
    7. +

      Let compress pointer be another pointer into + address’s 16-bit pieces, initially null and pointing to nothing. -

    8. Let pointer be a pointer into +

      +
    9. +
    10. +

      Let pointer be a pointer into input, initially zero (pointing to the first code point). -

    11. -

      If c is ":", run these substeps: - -

        -
      1. If remaining does not start with - ":", parse error, return failure. - -

      2. Increase pointer by two. - -

      3. Increase piece pointer by one and then set +

        +
      4. +
      5. + +

        If c is ":", run these substeps: + +

        +
          + +
        1. +

          If remaining does not start with + ":", parse error, return failure. + +

          +
        2. +
        3. +

          Increase pointer by two. + +

          +
        4. +
        5. +

          Increase piece pointer by one and then set compress pointer to piece pointer. -

        +

        +
      6. +
      + -
    12. -

      Main: - While c is not the EOF code point, run these + +

    13. +
    14. + +

      Main: + While c is not the EOF code point, run these substeps: -

        -
      1. If piece pointer is eight, - parse error, return failure. - -

      2. -

        If c is ":", run these inner +

        +
          + +
        1. +

          If piece pointer is eight, + parse error, return failure. + +

          +
        2. +
        3. + +

          If c is ":", run these inner substeps: -

            -
          1. If compress pointer is not null, - parse error, return failure. +

            +
              + +
            1. +

              If compress pointer is not null, + parse error, return failure. -

            2. Increase pointer and piece pointer by one, set +

              +
            3. +
            4. Increase pointer and piece pointer by one, set compress pointer to piece pointer, - and then jump to Main. -
            - -
          2. Let value and length be 0. - -

          3. While length is less than 4 and - c is an - ASCII hex digit, set + and then jump to Main. +

          4. +
          + + + +
        4. +
        5. +

          Let value and length be 0. + +

          +
        6. +
        7. +

          While length is less than 4 and + c is an + ASCII hex digit, set value to - value × 0x10 + c interpreted as hexadecimal number, + value × 0x10 + c interpreted as hexadecimal number, and increase pointer and length by one. -

        8. -

          Based on c: +

          +
        9. +
        10. + +

          Based on c: -

          -
          "." -
          -

          If length is 0, parse error, +

          +
          + +
          "." +
          +
          + +

          If length is 0, parse error, return failure. -

          Decrease pointer by length. -

          Jump to IPv4. +

          +

          Decrease pointer by length. +

          +

          Jump to IPv4. + +

          +
          +
          ":" +
          +
          + +

          Increase pointer by one. +

          +

          If c is the EOF code point, + parse error, return failure. + +

          +
          +
          Anything but the EOF code point +
          +
          +

          Parse error, return failure. +

          +
          +
          + + + +
        11. +
        12. +

          Set piece to value. + +

          +
        13. +
        14. +

          Increase piece pointer by one. +

          +
        15. +
        + -
        ":" -
        -

        Increase pointer by one. -

        If c is the EOF code point, - parse error, return failure. - -

        Anything but the EOF code point -

        Parse error, return failure. - - -

      3. Set piece to value. - -

      4. Increase piece pointer by one. -

      - -
    15. If c is the EOF code point, jump to - Finale. + +

    16. +
    17. +

      If c is the EOF code point, jump to + Finale. -

    18. IPv4: +

      +
    19. +
    20. +

      IPv4: If piece pointer is greater than six, - parse error, return failure. + parse error, return failure. -

    21. Let dots seen be 0. +

      +
    22. +
    23. +

      Let dots seen be 0. -

    24. -

      While c is not the EOF code point, run +

      +
    25. +
    26. + +

      While c is not the EOF code point, run these substeps: -

        -
      1. Let value be null. - -

      2. If c is not an ASCII digit, - parse error, return failure. - -

      3. -

        While c is an - ASCII digit, run these subsubsteps: - -

          -
        1. Let number be c interpreted as decimal number. - -

        2. -

          If value is null, set value to number. - -

          Otherwise, if value is 0, parse error, return failure. - -

          Otherwise, set value to value × 10 + number. - -

        3. Increase pointer by one. - -

        4. If value is greater than 255, parse error, +

          +
            + +
          1. +

            Let value be null. + +

            +
          2. +
          3. +

            If c is not an ASCII digit, + parse error, return failure. + +

            +
          4. +
          5. + +

            While c is an + ASCII digit, run these subsubsteps: + +

            +
              + +
            1. +

              Let number be c interpreted as decimal number. + +

              +
            2. +
            3. + +

              If value is null, set value to number. + +

              +

              Otherwise, if value is 0, parse error, return failure. + +

              +

              Otherwise, set value to value × 10 + number. + +

              +
            4. +
            5. +

              Increase pointer by one. + +

              +
            6. +
            7. +

              If value is greater than 255, parse error, return failure. -

            - -
          6. If dots seen is less than 3 and - c is not a ".", - parse error, return failure. - -

          7. Set piece to +

            +
          8. +
          + + + +
        5. +
        6. +

          If dots seen is less than 3 and + c is not a ".", + parse error, return failure. + +

          +
        7. +
        8. +

          Set piece to piece × 0x100 + value. -

        9. If dots seen is 1 or 3, increase +

          +
        10. +
        11. +

          If dots seen is 1 or 3, increase piece pointer by one. -

        12. Increase pointer by one. +

          +
        13. +
        14. +

          Increase pointer by one. + +

          +
        15. +
        16. +

          If dots seen is 3 and c is not + the EOF code point, + parse error, return failure. + +

          +
        17. +
        18. +

          Increase dots seen by one. +

          +
        19. +
        + -
      4. If dots seen is 3 and c is not - the EOF code point, - parse error, return failure. - -

      5. Increase dots seen by one. -

      - -
    27. -

      Finale: + +

    28. +
    29. + +

      Finale: If compress pointer is not null, run these substeps: -

        -
      1. Let swaps be +

        +
          + +
        1. +

          Let swaps be piece pointercompress pointer. -

        2. Set piece pointer to seven. +

          +
        3. +
        4. +

          Set piece pointer to seven. -

        5. While piece pointer is not zero and swaps is +

          +
        6. +
        7. +

          While piece pointer is not zero and swaps is greater than zero, swap piece with the - piece at pointer + piece at pointer compress pointer + swaps − 1, and then decrease both piece pointer and swaps by one. -

        +

        +
      2. +
      + -
    30. Otherwise, if compress pointer is null and - piece pointer is not eight, parse error, + +

    31. +
    32. +

      Otherwise, if compress pointer is null and + piece pointer is not eight, parse error, return failure. -

    33. Return address. -

    +

    +
  2. +
  3. +

    Return address. +

    +
+ -

3.4. Host serializing

+

3.4. Host serializing

-

The host serializer takes null or a -host host and then runs + +

The host serializer takes null or a +host host and then runs these steps: -

    -
  1. If host is null, return the empty string. +

    +
      + +
    1. +

      If host is null, return the empty string. -

    2. If host is an - IPv6 address, return +

      +
    3. +
    4. +

      If host is an + IPv6 address, return "[", followed by the result of running the - IPv6 serializer on host, + IPv6 serializer on host, followed by "]". -

    5. Otherwise, host is a domain, +

      +
    6. +
    7. +

      Otherwise, host is a domain, return host. -

    +

    +
+ -

The IPv6 serializer takes an -IPv6 address address and +

The IPv6 serializer takes an +IPv6 address address and then runs these steps: -

    -
  1. Let output be the empty string. +

    +
      + +
    1. +

      Let output be the empty string. -

    2. -

      Let compress pointer be a pointer to the first - 16-bit piece in the first longest +

      +
    3. +
    4. + +

      Let compress pointer be a pointer to the first + 16-bit piece in the first longest sequences of address’s - 16-bit pieces that are 0. + 16-bit pieces that are 0. -

      In 0:f:0:0:f:f:0:0 it would point to +

      +

      In 0:f:0:0:f:f:0:0 it would point to the second 0. -

    5. If there is no sequence of address’s - 16-bit pieces that are 0 longer than +

      +
    6. +
    7. +

      If there is no sequence of address’s + 16-bit pieces that are 0 longer than one, set compress pointer to null. -

    8. -

      For each piece in address’s - pieces, run these substeps: - -

        -
      1. If compress pointer points to +

        +
      2. +
      3. + +

        For each piece in address’s + pieces, run these substeps: + +

        +
          + +
        1. +

          If compress pointer points to piece, append "::" to output if piece is - address’s first piece and append + address’s first piece and append ":" otherwise, and then run these substeps again with all - subsequent pieces in - address’s pieces + subsequent pieces in + address’s pieces that are 0 skipped or go the next step in the overall set of steps if - that leaves no pieces. + that leaves no pieces. -

        2. Append piece, represented as the shortest +

          +
        3. +
        4. +

          Append piece, represented as the shortest possible lowercase hexadecimal number, to output. -

        5. If piece is not - address’s last piece, +

          +
        6. +
        7. +

          If piece is not + address’s last piece, append ":" to output. -

        +

        +
      4. +
      + + + +
    9. +
    10. +

      Return output. +

      +
    -
  2. Return output. -

-

This algorithm requires the recommendation from +

This algorithm requires the recommendation from A Recommendation for IPv6 Address Text Representation. -[RFC5952] +[RFC5952] -

4. URLs

+

+

4. URLs

+ -

A URL is a universal identifier. +

A URL is a universal identifier. -

A URL consists of components, namely a -scheme, -scheme data, -username, -password, -host, -port, -path, -query, and -fragment. +

+

A URL consists of components, namely a +scheme, +scheme data, +username, +password, +host, +port, +path, +query, and +fragment. -

A URL’s scheme is -a string that identifies the type of URL and can be used to -dispatch a URL for further processing after -parsing. It is initially the empty string. +

+

A URL’s scheme is +a string that identifies the type of URL and can be used to +dispatch a URL for further processing after +parsing. It is initially the empty string. -

A URL’s -scheme data is a string holding the contents of a -URL. It is initially the empty string. +

+

A URL’s +scheme data is a string holding the contents of a +URL. It is initially the empty string. -

A URL’s -scheme data will be its initial value if its -scheme is a relative scheme, and +

+

A URL’s +scheme data will be its initial value if its +scheme is a relative scheme, and otherwise will be the only component without an initial value. -

A URL’s username +

+

A URL’s username is a string identifying a user. It is initially the empty string. -

A URL’s password +

+

A URL’s password is either null or a string identifying a user’s credentials. It is initially null. -

A URL’s host is -either null or a host. It is initially null. +

+

A URL’s host is +either null or a host. It is initially null. -

A URL’s port is a +

+

A URL’s port is a string that identifies a networking port. It is initially the empty string. -

A URL’s path is a +

+

A URL’s path is a list of zero or more strings holding data, usually identifying a location in hierarchical form. It is initially the empty list. -

A URL’s query is +

+

A URL’s query is either null or a string holding data. It is initially null. -

A URL’s fragment +

+

A URL’s fragment is either null or a string holding data that can be used for further processing on the -resource the URL’s other components identify. +resource the URL’s other components identify. It is initially null. -

A URL also has an associated relative flag. +

+

A URL also has an associated relative flag. It is initially unset. -

The relative flag exists as checking if a -URL’s scheme is a -relative scheme can give incorrect results due to the -protocol attribute. +

+

The relative flag exists as checking if a +URL’s scheme is a +relative scheme can give incorrect results due to the +protocol attribute. -

A URL also has an associated -object that is either null or a -Blob. It is initially null. -[FILEAPI] +

+

A URL also has an associated +object that is either null or a +Blob. It is initially null. +[FILEAPI] -

At this point this is used primarily to support "blob" +

+

At this point this is used primarily to support "blob" URLs, but others can be added going forward, hence "object". -

A relative scheme is a -scheme listed in the first column of -the following table. A default port is a -relative scheme’s optional corresponding -port and is listed in the second column +

+

A relative scheme is a +scheme listed in the first column of +the following table. A default port is a +relative scheme’s optional corresponding +port and is listed in the second column on the same row. - -
scheme - port -
"ftp""21" -
"file" -
"gopher""70" -
"http""80" -
"https""443" -
"ws""80" -
"wss""443" -
- -

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
scheme + port +
"ftp""21" +
"file" +
"gopher""70" +
"http""80" +
"https""443" +
"ws""80" +
"wss""443" +
+ + +

+ + +

A URL +includes credentials if either its +username is not the empty string or its +password is non-null. -

A URL -includes credentials if either its -username is not the empty string or its -password is non-null. +

+

A URL can be designated as +base URL. -

A URL can be designated as -base URL. +

+

A base URL is useful for +the URL parser when the input is potentially a +relative URL. -

A base URL is useful for -the URL parser when the input is potentially a -relative URL. +

+

4.1. URL writing

-

4.1. URL writing

-

A URL must be written as either a -relative URL or an -absolute URL, optionally followed by +

A URL must be written as either a +relative URL or an +absolute URL, optionally followed by "#" and a -fragment. +fragment. -

An absolute URL must be a -scheme, followed by +

+

An absolute URL must be a +scheme, followed by ":", followed by either a -scheme-relative URL, if -scheme is a relative scheme, or -scheme data otherwise, optionally followed -by "?" and a query. - -

A scheme must be one -ASCII alpha, followed by zero or more of -ASCII alphanumeric, "+", +scheme-relative URL, if +scheme is a relative scheme, or +scheme data otherwise, optionally followed +by "?" and a query. + +

+

A scheme must be one +ASCII alpha, followed by zero or more of +ASCII alphanumeric, "+", "-", and ".". A -scheme must be registered -.... +scheme must be registered +.... -

The syntax of scheme data -depends on the scheme and is typically +

+

The syntax of scheme data +depends on the scheme and is typically defined alongside it. Standards must define -scheme data within the constraints of zero or -more URL units, excluding "?". - -

A relative URL must be either a -scheme-relative URL, an -absolute-path-relative URL, -or a path-relative URL that -does not start with a scheme and +scheme data within the constraints of zero or +more URL units, excluding "?". + +

+

A relative URL must be either a +scheme-relative URL, an +absolute-path-relative URL, +or a path-relative URL that +does not start with a scheme and ":", optionally followed by a "?" and -a query. +a query. -

At the point where a relative URL is -parsed, a -base URL must be in scope. +

+

At the point where a relative URL is +parsed, a +base URL must be in scope. -

A scheme-relative URL must be +

+

A scheme-relative URL must be "//", optionally followed by -userinfo and "@", -followed by a host, optionally followed -by ":" and a port, +userinfo and "@", +followed by a host, optionally followed +by ":" and a port, optionally followed by an -absolute-path-relative URL. +absolute-path-relative URL. -

Userinfo must be a -username, optionally followed by a +

+

Userinfo must be a +username, optionally followed by a ":" and a -password. +password. -

A username must be zero or more -URL units, excluding "/", +

+

A username must be zero or more +URL units, excluding "/", ":, "?", and "@". -

A password must be zero or more -URL units, excluding "/", +

+

A password must be zero or more +URL units, excluding "/", "?", and "@". -

A port must be zero or more -ASCII digits. +

+

A port must be zero or more +ASCII digits. -

An -absolute-path-relative URL +

+

An +absolute-path-relative URL must be "/", followed by a -path-relative URL that does not +path-relative URL that does not start with "/". -

A path-relative URL must be zero or -more path segments separated from each +

+

A path-relative URL must be zero or +more path segments separated from each other by a "/". -

A path segment must be zero or more URL units, +

+

A path segment must be zero or more URL units, excluding "/" and "?". -

A query must be zero or more -URL units. +

+

A query must be zero or more +URL units. -

A fragment must be zero or more -URL units. +

+

A fragment must be zero or more +URL units. -

The URL code points are ASCII alphanumeric, +

+

The URL code points are ASCII alphanumeric, "!", "$", "&", @@ -851,1002 +1389,1784 @@

4.1. U+F0000 to U+FFFFD, U+100000 to U+10FFFD. -

Code points higher than U+009F will be converted to -percent-encoded bytes by the -URL parser, except for code points appearing in -fragments. +

+

Code points higher than U+009F will be converted to +percent-encoded bytes by the +URL parser, except for code points appearing in +fragments. + +

+

The URL units are URL code points and +percent-encoded bytes. -

The URL units are URL code points and -percent-encoded bytes. +

+

4.2. URL parsing

-

4.2. URL parsing

-

Add the ability to halt on the first conformance error. +

Add the ability to halt on the first conformance error. -

The URL parser takes a string +

+

The URL parser takes a string input, optionally with a -base URL base, and -optionally with an encoding +base URL base, and +optionally with an encoding encoding override, and then runs these steps: -

    -
  1. Let url be the result of running the - basic URL parser on input +

    +
      + +
    1. +

      Let url be the result of running the + basic URL parser on input with base, and encoding override as provided. -

    2. If url is failure, return failure. +

      +
    3. +
    4. +

      If url is failure, return failure. -

    5. If url’s scheme is not +

      +
    6. +
    7. +

      If url’s scheme is not "blob", return url. -

    8. If url’s scheme data - is not in the blob URL store, return - url. [FILEAPI] +

      +
    9. +
    10. +

      If url’s scheme data + is not in the blob URL store, return + url. [FILEAPI] + +

      +
    11. +
    12. +

      Set url’s object to a + structured clone of the entry in the + blob URL store corresponding to + url’s scheme data. + [HTML] + +

      +
    13. +
    14. +

      Return url. +

      +
    -
  2. Set url’s object to a - structured clone of the entry in the - blob URL store corresponding to - url’s scheme data. - [HTML] -

  3. Return url. -

+
-
-

The basic URL parser takes a string +

The basic URL parser takes a string input, optionally with a -base URL base, -optionally with an encoding +base URL base, +optionally with an encoding encoding override, optionally with an -URL url and a state override +URL url and a state override state override, and then runs these steps: -

-

The encoding override argument is a legacy concept only relevant for +

+
+ +

The encoding override argument is a legacy concept only relevant for HTML. The url and state override arguments are only for - use by methods of objects implementing the URLUtils interface. - [HTML] + use by methods of objects implementing the URLUtils interface. + [HTML] -

When the url and state override arguments are not - passed the basic URL parser returns either a - URL or failure. If they are passed the +

+

When the url and state override arguments are not + passed the basic URL parser returns either a + URL or failure. If they are passed the algorithm simply modifies the passed url and can terminate without returning anything. -

+

-
    -
  1. -

    If url is not given: -

      -
    1. Set url to a new URL. - -

    2. Remove any leading and trailing - ASCII whitespace from +

        + +
      1. + +

        If url is not given: + +

        +
          + +
        1. +

          Set url to a new URL. + +

          +
        2. +
        3. +

          Remove any leading and trailing + ASCII whitespace from input. -

        +

        +
      2. +
      + -
    3. Let state be state override - if given, or scheme start state otherwise. + +

    4. +
    5. +

      Let state be state override + if given, or scheme start state otherwise. -

    6. If base is not given, set it to null. +

      +
    7. +
    8. +

      If base is not given, set it to null. -

    9. If encoding override is not given, set it to - utf-8. +

      +
    10. +
    11. +

      If encoding override is not given, set it to + utf-8. -

    12. Let buffer be the empty string. +

      +
    13. +
    14. +

      Let buffer be the empty string. -

    15. Let the @ flag and the [] flag be +

      +
    16. +
    17. +

      Let the @ flag and the [] flag be unset. -

    18. Let pointer be a pointer to first code point in +

      +
    19. +
    20. +

      Let pointer be a pointer to first code point in input. -

    21. -

      Keep running the following state machine by switching on state. If - after a run pointer points to the EOF code point, go to +

      +
    22. +
    23. + +

      Keep running the following state machine by switching on state. If + after a run pointer points to the EOF code point, go to the next step. Otherwise, increase pointer by one and continue with the state machine. -

      -
      scheme start state -
      -
        -
      1. If c is an ASCII alpha, - append c, lowercased, to buffer, and - set state to scheme state. - -

      2. Otherwise, if state override is not given, set - state to no scheme state, and decrease +

        +
        + +
        scheme start state +
        +
        + +
          + +
        1. +

          If c is an ASCII alpha, + append c, lowercased, to buffer, and + set state to scheme state. + +

          +
        2. +
        3. +

          Otherwise, if state override is not given, set + state to no scheme state, and decrease pointer by one. -

        4. Otherwise, parse error, terminate this algorithm. -

        - -
        scheme state -
        -
          -
        1. If c is an ASCII alphanumeric, +

          +
        2. +
        3. +

          Otherwise, parse error, terminate this algorithm. +

          +
        4. +
        + + + +
        +
        scheme state +
        +
        + +
          + +
        1. +

          If c is an ASCII alphanumeric, "+", "-", or - ".", append c, lowercased, to + ".", append c, lowercased, to buffer. -

        2. -

          Otherwise, if c is ":", set - url’s scheme to +

          +
        3. +
        4. + +

          Otherwise, if c is ":", set + url’s scheme to buffer, buffer to the empty string, and then run these substeps: -

            -
          1. If state override is given, +

            +
              + +
            1. +

              If state override is given, terminate this algorithm. -

            2. If url’s - scheme is - a relative scheme, set url’s - relative flag. - -

            3. If url’s - scheme is +

              +
            4. +
            5. +

              If url’s + scheme is + a relative scheme, set url’s + relative flag. + +

              +
            6. +
            7. +

              If url’s + scheme is "file", set state to - relative state. + relative state. -

            8. Otherwise, if url’s - relative flag is set, base is not null +

              +
            9. +
            10. +

              Otherwise, if url’s + relative flag is set, base is not null and base’s - scheme is equal to - url’s scheme, + scheme is equal to + url’s scheme, set state to - relative or authority state. - -

            11. Otherwise, if url’s - relative flag is set, set state to - authority first slash state. + relative or authority state. + +

              +
            12. +
            13. +

              Otherwise, if url’s + relative flag is set, set state to + authority first slash state. + +

              +
            14. +
            15. +

              Otherwise, set state to + scheme data state. +

              +
            16. +
            + -
          2. Otherwise, set state to - scheme data state. -

          - -
        5. Otherwise, if state override is not given, set + +

        6. +
        7. +

          Otherwise, if state override is not given, set buffer to the empty string, state to - no scheme state, and start over (from the first code point + no scheme state, and start over (from the first code point in input). -

        8. Otherwise, if c is the - EOF code point, terminate this algorithm. +

          +
        9. +
        10. +

          Otherwise, if c is the + EOF code point, terminate this algorithm. -

        11. Otherwise, parse error, terminate this algorithm. -

        - -
        scheme data state -
        -
          -
        1. If c is "?", set - url’s query +

          +
        2. +
        3. +

          Otherwise, parse error, terminate this algorithm. +

          +
        4. +
        + + + +
        +
        scheme data state +
        +
        + +
          + +
        1. +

          If c is "?", set + url’s query to the empty string and state to - query state. + query state. -

        2. Otherwise, if c is "#", set - url’s fragment +

          +
        3. +
        4. +

          Otherwise, if c is "#", set + url’s fragment to the empty string and state to - fragment state. - -

        5. -

          Otherwise, run these substeps: - -

            -
          1. If c is not the EOF code point, not a - URL code point, and not - "%", parse error. + fragment state. -

          2. If c is "%" and remaining does - not start with two ASCII hex digits, parse error. +

            +
          3. +
          4. + +

            Otherwise, run these substeps: -

          5. If c is none of - EOF code point, U+0009, U+000A, and U+000D, - utf-8 percent encode c using the - simple encode set, and append the result to +

            +
              + +
            1. +

              If c is not the EOF code point, not a + URL code point, and not + "%", parse error. + +

              +
            2. +
            3. +

              If c is "%" and remaining does + not start with two ASCII hex digits, parse error. + +

              +
            4. +
            5. +

              If c is none of + EOF code point, U+0009, U+000A, and U+000D, + utf-8 percent encode c using the + simple encode set, and append the result to url’s - scheme data. -

            -
          - -
          no scheme state -
          -

          If base is null, or base’s - scheme is not a - relative scheme, parse error, return failure. - -

          Due to the protocol attribute’s + scheme data. +

          +
        6. +
        + + +
      3. +
      + + + +
      +
      no scheme state +
      +
      + +

      If base is null, or base’s + scheme is not a + relative scheme, parse error, return failure. + +

      +

      Due to the protocol attribute’s ability to change base’s - scheme, base’s - relative flag is not used here. + scheme, base’s + relative flag is not used here. -

      Otherwise, set state to relative state, +

      +

      Otherwise, set state to relative state, and decrease pointer by one. -

      relative or authority state -
      -

      If c is "/" and - remaining starts with "/", set - state to authority ignore slashes state +

      +
      +
      relative or authority state +
      +
      + +

      If c is "/" and + remaining starts with "/", set + state to authority ignore slashes state and increase pointer by one. -

      Otherwise, parse error, set state to - relative state and decrease pointer by +

      +

      Otherwise, parse error, set state to + relative state and decrease pointer by one. -

      relative state -
      -

      Set url’s relative flag, set - url’s scheme to - base’s scheme if - url’s scheme is not - "file", and then, based on c: - -

      -
      EOF code point -
      -

      Set url’s host - to base’s host, - url’s port to - base’s port, - url’s path to - base’s path, and - url’s query to - base’s query. - -

      "/" -
      "\" -
      -
        -
      1. If c is "\", - parse error. -

      2. Set state to - relative slash state. -

      - -
      "?" -

      Set - url’s host to - base’s host, - url’s port to - base’s port, - url’s path to - base’s path, - url’s query to the empty string, - and state to query state. - -

      "#" -

      Set - url’s host to - base’s host, - url’s port to - base’s port, - url’s path to - base’s path, - url’s query to - base’s query, - url’s fragment to the empty string, - and state to fragment state. - -

      Otherwise -
      -
        -
      1. -

        If url’s scheme is not +

        +
      +
      relative state +
      +
      + +

      Set url’s relative flag, set + url’s scheme to + base’s scheme if + url’s scheme is not + "file", and then, based on c: + +

      +
      + +
      EOF code point +
      +
      + +

      Set url’s host + to base’s host, + url’s port to + base’s port, + url’s path to + base’s path, and + url’s query to + base’s query. + +

      +
      +
      "/" +
      +
      "\" +
      +
      + +
        + +
      1. +

        If c is "\", + parse error. +

        +
      2. +
      3. +

        Set state to + relative slash state. +

        +
      4. +
      + + + +
      +
      "?" +
      +
      +

      Set + url’s host to + base’s host, + url’s port to + base’s port, + url’s path to + base’s path, + url’s query to the empty string, + and state to query state. + +

      +
      +
      "#" +
      +
      +

      Set + url’s host to + base’s host, + url’s port to + base’s port, + url’s path to + base’s path, + url’s query to + base’s query, + url’s fragment to the empty string, + and state to fragment state. + +

      +
      +
      Otherwise +
      +
      + +
        + +
      1. + +

        If url’s scheme is not "file", or c is not an - ASCII alpha, or remaining does not start with either - ":" or "|", or remaining - consists of one code point, or remaining’s second code point is + ASCII alpha, or remaining does not start with either + ":" or "|", or remaining + consists of one code point, or remaining’s second code point is not one of "/", "\", "?", and "#", then set - url’s host to - base’s host, - url’s port to - base’s port, - url’s path to - base’s path, and then remove - url’s path’s last entry. + url’s host to + base’s host, + url’s port to + base’s port, + url’s path to + base’s path, and then remove + url’s path’s last entry. -

        This is a (platform-independent) Windows drive letter quirk. +

        +

        This is a (platform-independent) Windows drive letter quirk. When found at the start of a file URL it is treated as an absolute path rather than one relative to - base’s path. + base’s path. -

      2. Set state to relative path state, +

        +
      3. +
      4. +

        Set state to relative path state, and decrease pointer by one. -

      -
      - -
      relative slash state -
      -

      If c is either "/" or +

      +
    24. +
    + + + + + + + + +
    relative slash state +
    +
    + +

    If c is either "/" or "\", run these steps: -

      -
    1. If c is "\", - parse error. - -

    2. If url’s - scheme is +

      +
        + +
      1. +

        If c is "\", + parse error. + +

        +
      2. +
      3. +

        If url’s + scheme is "file", set state to - file host state. - -

      4. Otherwise, set state to - authority ignore slashes state. -

      - -

      Otherwise, run these steps: - -

        -
      1. -

        If url’s scheme is not + file host state. + +

        +
      2. +
      3. +

        Otherwise, set state to + authority ignore slashes state. +

        +
      4. +
      + + + +

      Otherwise, run these steps: + +

      +
        + +
      1. + +

        If url’s scheme is not "file", set - url’s host to - base’s host and - url’s port to - base’s port. - -

        file:/path/ will not inherit - base’s host. - -

      2. Set state to relative path state, + url’s host to + base’s host and + url’s port to + base’s port. + +

        +

        file:/path/ will not inherit + base’s host. + +

        +
      3. +
      4. +

        Set state to relative path state, and decrease pointer by one. -

      - -
      authority first slash state -
      -

      If c is "/", set - state to authority second slash state. - -

      Otherwise, parse error, set state to - authority ignore slashes state, and decrease +

      +
    3. +
    + + + +
    +
    authority first slash state +
    +
    + +

    If c is "/", set + state to authority second slash state. + +

    +

    Otherwise, parse error, set state to + authority ignore slashes state, and decrease pointer by one. -

    authority second slash state -
    -

    If c is "/", set - state to authority ignore slashes state. - -

    Otherwise, parse error, set state to - authority ignore slashes state, and decrease +

    +
    +
    authority second slash state +
    +
    + +

    If c is "/", set + state to authority ignore slashes state. + +

    +

    Otherwise, parse error, set state to + authority ignore slashes state, and decrease pointer by one. -

    authority ignore slashes state -
    -

    If c is neither "/" nor +

    +
    +
    authority ignore slashes state +
    +
    + +

    If c is neither "/" nor "\", set state to - authority state, and decrease pointer by one. - -

    Otherwise, parse error. - -

    authority state -
    -
      -
    1. -

      If c is "@", run these substeps: + authority state, and decrease pointer by one. + +

      +

      Otherwise, parse error. + +

      +
    +
    authority state +
    +
    + +
      + +
    1. + +

      If c is "@", run these substeps: -

        -
      1. If the @ flag is set, - parse error, prepend "%40" to +

        +
          + +
        1. +

          If the @ flag is set, + parse error, prepend "%40" to buffer. -

        2. Set the @ flag. - -

        3. -

          For each code point in buffer, run these substeps: - -

            -
          1. If code point is U+0009, U+000A, or U+000D, - parse error, continue. +

            +
          2. +
          3. +

            Set the @ flag. -

          4. If code point is not a - URL code point and not - "%", parse error. - -

          5. If code point is "%" and - remaining does not start with two - ASCII hex digits, parse error. - -

          6. If code point is ":" and +

            +
          7. +
          8. + +

            For each code point in buffer, run these substeps: + +

            +
              + +
            1. +

              If code point is U+0009, U+000A, or U+000D, + parse error, continue. + +

              +
            2. +
            3. +

              If code point is not a + URL code point and not + "%", parse error. + +

              +
            4. +
            5. +

              If code point is "%" and + remaining does not start with two + ASCII hex digits, parse error. + +

              +
            6. +
            7. +

              If code point is ":" and url’s - password is null, set - url’s password + password is null, set + url’s password to the empty string and continue. -

            8. utf-8 percent encode code point using - the default encode set and append the result to - url’s password - if url’s password +

              +
            9. +
            10. +

              utf-8 percent encode code point using + the default encode set and append the result to + url’s password + if url’s password is non-null, and to - url’s username + url’s username otherwise. -

            -
          9. Set buffer to the empty string. -

          +

          +
        4. +
        + + +
      2. +
      3. +

        Set buffer to the empty string. +

        +
      4. +
      + -
    2. Otherwise, if c is one of EOF code point, + +

    3. +
    4. +

      Otherwise, if c is one of EOF code point, "/", "\", "?", and "#", decrease pointer by the number of code points in buffer plus one, set buffer to the empty string, and - state to host state. - -

    5. Otherwise, append c to buffer. -

    - -
    file host state -
    -
      -
    1. -

      If c is one of EOF code point, + state to host state. + +

      +
    2. +
    3. +

      Otherwise, append c to buffer. +

      +
    4. +
    + + + +
    +
    file host state +
    +
    + +
      + +
    1. + +

      If c is one of EOF code point, "/", "\", "?", and "#", decrease pointer by one, and run these substeps: -

        -
      1. -

        If buffer consists of two code points, of - which the first is an ASCII alpha and the second is +

        +
          + +
        1. + +

          If buffer consists of two code points, of + which the first is an ASCII alpha and the second is either ":" or "|", set - state to relative path state. + state to relative path state. -

          This is a (platform-independent) Windows drive letter quirk. +

          +

          This is a (platform-independent) Windows drive letter quirk. buffer is not reset here and instead used in the - relative path state. - -

        2. Otherwise, if buffer is the empty string, set - state to relative path start state. + relative path state. -

        3. -

          Otherwise, run these steps: +

          +
        4. +
        5. +

          Otherwise, if buffer is the empty string, set + state to relative path start state. -

            -
          1. Let host be the result of - host parsing +

            +
          2. +
          3. + +

            Otherwise, run these steps: + +

            +
              + +
            1. +

              Let host be the result of + host parsing buffer. -

            2. If host is failure, return failure. +

              +
            3. +
            4. +

              If host is failure, return failure. -

            5. Set - url’s host to +

              +
            6. +
            7. +

              Set + url’s host to host, buffer to the empty string, - and state to relative path start state. -

            -
          - -
        6. Otherwise, if c is U+0009, U+000A, or U+000D, - parse error. - -

        7. Otherwise, append c to buffer. -

        - -
        host state -
        hostname state -
        -
          -
        1. -

          If c is ":" and the + and state to relative path start state. +

          +
        2. +
        + + +
      2. +
      + + + +
    2. +
    3. +

      Otherwise, if c is U+0009, U+000A, or U+000D, + parse error. + +

      +
    4. +
    5. +

      Otherwise, append c to buffer. +

      +
    6. +
    + + + +
    +
    host state +
    +
    hostname state +
    +
    + +
      + +
    1. + +

      If c is ":" and the [] flag is unset, run these substeps: -

        -
      1. Let host be the result of - host parsing +

        +
          + +
        1. +

          Let host be the result of + host parsing buffer. -

        2. If host is failure, return failure. +

          +
        3. +
        4. +

          If host is failure, return failure. -

        5. Set url’s host to +

          +
        6. +
        7. +

          Set url’s host to host, buffer to the empty string, - and state to port state. + and state to port state. -

        8. If state override is hostname state, +

          +
        9. +
        10. +

          If state override is hostname state, terminate this algorithm. -

        +

        +
      2. +
      + -
    2. -

      Otherwise, if c is the - EOF code point, "/", + +

    3. +
    4. + +

      Otherwise, if c is the + EOF code point, "/", "\", "?", or "#", decrease pointer by one, and run these substeps: -

        -
      1. Let host be the result of - host parsing +

        +
          + +
        1. +

          Let host be the result of + host parsing buffer. -

        2. If host is failure, return failure. +

          +
        3. +
        4. +

          If host is failure, return failure. -

        5. Set url’s host to +

          +
        6. +
        7. +

          Set url’s host to host, buffer to the empty string, - and state to relative path start state. + and state to relative path start state. -

        8. If state override is given, terminate this +

          +
        9. +
        10. +

          If state override is given, terminate this algorithm. -

        - -
      2. Otherwise, if c is U+0009, U+000A, or U+000D, - parse error. - -

      3. -

        Otherwise, run these substeps: +

        +
      4. +
      + -
        -
      1. If c is "[", set the + +

      2. +
      3. +

        Otherwise, if c is U+0009, U+000A, or U+000D, + parse error. + +

        +
      4. +
      5. + +

        Otherwise, run these substeps: + +

        +
          + +
        1. +

          If c is "[", set the [] flag. -

        2. If c is "]", unset the +

          +
        3. +
        4. +

          If c is "]", unset the [] flag. -

        5. Append c to buffer. -

        -
      - -
      port state -
      -
        -
      1. If c is an ASCII digit, - append c to buffer. - -

      2. -

        Otherwise, if c is one of - EOF code point, "/", +

        +
      3. +
      4. +

        Append c to buffer. +

        +
      5. +
      + + +
    5. +
    + + + +
    +
    port state +
    +
    + +
      + +
    1. +

      If c is an ASCII digit, + append c to buffer. + +

      +
    2. +
    3. + +

      Otherwise, if c is one of + EOF code point, "/", "\", "?", and "#", or state override is given, run these substeps: -

        -
      1. -

        Remove leading U+0030 code points from buffer +

        +
          + +
        1. + +

          Remove leading U+0030 code points from buffer until either the leading code point is not U+0030 or buffer is one code point. -

          - -
          InputOutput -
          "42""42" -
          "031""31" -
          "080""80" -
          "0000""0" -
          -
          - -
        2. If buffer is equal to - url’s scheme’s - default port, set buffer to the empty +

          +
          + + + + + + + + + + + + + + + + + + + + + + + + + +
          InputOutput +
          "42""42" +
          "031""31" +
          "080""80" +
          "0000""0" +
          + + +
          + + + +
        3. +
        4. +

          If buffer is equal to + url’s scheme’s + default port, set buffer to the empty string. -

        5. Set url’s - port to buffer. +

          +
        6. +
        7. +

          Set url’s + port to buffer. -

        8. If state override is given, terminate this +

          +
        9. +
        10. +

          If state override is given, terminate this algorithm. -

        11. Set buffer to the empty string, - state to relative path start state, and +

          +
        12. +
        13. +

          Set buffer to the empty string, + state to relative path start state, and decrease pointer by one. -

        - -
      2. Otherwise, if c is U+0009, U+000A, or U+000D, - parse error. - -

      3. Otherwise, parse error, return failure. -

      - -
      relative path start state -
      -
        -
      1. If c is "\", - parse error. +

        +
      2. +
      + -
    4. Set state to relative path state - and if c is neither "/" nor + +

    5. +
    6. +

      Otherwise, if c is U+0009, U+000A, or U+000D, + parse error. + +

      +
    7. +
    8. +

      Otherwise, parse error, return failure. +

      +
    9. +
    + + + +
    +
    relative path start state +
    +
    + +
      + +
    1. +

      If c is "\", + parse error. + +

      +
    2. +
    3. +

      Set state to relative path state + and if c is neither "/" nor "\", decrease pointer by one. -

    - -
    relative path state -
    -
      -
    1. -

      If either c is one of - EOF code point, "/", and +

      +
    2. +
    + + + +
    +
    relative path state +
    +
    + +
      + +
    1. + +

      If either c is one of + EOF code point, "/", and "\", or state override is not given and - c is one of "?" and + c is one of "?" and "#", run these substeps: -

        -
      1. If c is "\", parse error. +

        +
          + +
        1. +

          If c is "\", parse error. -

        2. -

          If buffer, lowercased, matches any row in the first column of +

          +
        3. +
        4. + +

          If buffer, lowercased, matches any row in the first column of the following table, set buffer to the contents of the cell in the second column of the matched row: - -
          "%2e" "." -
          ".%2e" ".." -
          "%2e." -
          "%2e%2e" -
          +

          + + + + + + + + + + + + + + + + + + +
          "%2e" "." +
          ".%2e" ".." +
          "%2e." +
          "%2e%2e" +
          + -
        5. If buffer is "..", remove - url’s path’s last entry, if - any, and then if c is neither "/" nor + +

        6. +
        7. +

          If buffer is "..", remove + url’s path’s last entry, if + any, and then if c is neither "/" nor "\", append the empty string to url’s - path. + path. -

        8. Otherwise, if buffer is "." and - c is neither "/" nor "\", +

          +
        9. +
        10. +

          Otherwise, if buffer is "." and + c is neither "/" nor "\", append an empty string to - url’s path. + url’s path. -

        11. -

          Otherwise, if buffer is not +

          +
        12. +
        13. + +

          Otherwise, if buffer is not ".", run these subsubsteps: -

            -
          1. -

            If url’s scheme is - "file", url’s path +

            +
              + +
            1. + +

              If url’s scheme is + "file", url’s path is empty, buffer consists of two - code points, of which the first is an ASCII alpha, + code points, of which the first is an ASCII alpha, and the second is "|", replace the second code point in buffer with ":". -

              This is a (platform-independent) Windows drive letter quirk. +

              +

              This is a (platform-independent) Windows drive letter quirk. They are beautiful, no? -

            2. Append buffer to - url’s path. -

            - -
          2. Set buffer to the empty string. - -

          3. If c is "?", set - url’s query to the empty string, - and state to query state. - -

          4. If c is "#", set - url’s fragment to the empty string, - and state to fragment state. -

          - -
        14. Otherwise, if c is U+0009, U+000A, or U+000D, - parse error. - -

        15. -

          Otherwise, run these steps: - -

            -
          1. If c is not a - URL code point and not "%", - parse error. +

            +
          2. +
          3. +

            Append buffer to + url’s path. +

            +
          4. +
          + -
        16. If c is "%" and remaining does - not start with two ASCII hex digits, parse error. + +

        17. +
        18. +

          Set buffer to the empty string. + +

          +
        19. +
        20. +

          If c is "?", set + url’s query to the empty string, + and state to query state. + +

          +
        21. +
        22. +

          If c is "#", set + url’s fragment to the empty string, + and state to fragment state. +

          +
        23. +
        + -
      2. utf-8 percent encode c using the - default encode set, and append the result to + +

      3. +
      4. +

        Otherwise, if c is U+0009, U+000A, or U+000D, + parse error. + +

        +
      5. +
      6. + +

        Otherwise, run these steps: + +

        +
          + +
        1. +

          If c is not a + URL code point and not "%", + parse error. + +

          +
        2. +
        3. +

          If c is "%" and remaining does + not start with two ASCII hex digits, parse error. + +

          +
        4. +
        5. +

          utf-8 percent encode c using the + default encode set, and append the result to buffer. -

        -
      - -
      query state -
      -
        -
      1. -

        If c is the EOF code point, or - state override is not given and c +

        +
      2. +
      + + +
    2. +
    + + + +
    +
    query state +
    +
    + +
      + +
    1. + +

      If c is the EOF code point, or + state override is not given and c is "#", run these substeps: -

        -
      1. If url’s relative flag is unset or - url’s scheme is either +

        +
          + +
        1. +

          If url’s relative flag is unset or + url’s scheme is either "ws" or "wss", set - encoding override to utf-8. + encoding override to utf-8. -

        2. Set buffer to the result of - encoding +

          +
        3. +
        4. +

          Set buffer to the result of + encoding buffer using encoding override. -

        5. -

          For each byte in buffer run +

          +
        6. +
        7. + +

          For each byte in buffer run these subsubsteps: -

            -
          1. If byte is less than 0x21, greater than +

            +
              + +
            1. +

              If byte is less than 0x21, greater than 0x7E, or is one of 0x22, 0x23, 0x3C, 0x3E, and 0x60, append byte, - percent encoded, to - url’s query. + percent encoded, to + url’s query. -

            2. Otherwise, append a code point whose value is +

              +
            3. +
            4. +

              Otherwise, append a code point whose value is byte to url’s - query. -

            - -
          2. Set buffer to the empty string. + query. +

            +
          3. +
          + -
        8. If c is "#", set + +

        9. +
        10. +

          Set buffer to the empty string. + +

          +
        11. +
        12. +

          If c is "#", set url’s - fragment to the empty string, - and state to fragment state. -

        - -
      2. Otherwise, if c is U+0009, U+000A, or U+000D, - parse error. - -

      3. -

        Otherwise, run these substeps: - -

          -
        1. If c is not a - URL code point and not "%", - parse error. - -

        2. If c is "%" and remaining does - not start with two ASCII hex digits, parse error. - -

        3. Append c to buffer. -

        -
      - -
      fragment state -
      -

      Based on c: -

      -
      EOF code point -

      Do nothing. - -

      U+0000 -
      U+0009 -
      U+000A -
      U+000D -

      Parse error. - -

      Otherwise -
      -
        -
      1. If c is not a URL code point and not - "%", parse error. - -

      2. If c is "%" and remaining does - not start with two ASCII hex digits, parse error. + fragment to the empty string, + and state to fragment state. +

        +
      3. +
      + -
    2. -

      Append c to url’s fragment. + +

    3. +
    4. +

      Otherwise, if c is U+0009, U+000A, or U+000D, + parse error. + +

      +
    5. +
    6. + +

      Otherwise, run these substeps: + +

      +
        + +
      1. +

        If c is not a + URL code point and not "%", + parse error. + +

        +
      2. +
      3. +

        If c is "%" and remaining does + not start with two ASCII hex digits, parse error. + +

        +
      4. +
      5. +

        Append c to buffer. +

        +
      6. +
      + + +
    7. +
    + + + +
    +
    fragment state +
    +
    + +

    Based on c: +

    +
    + +
    EOF code point +
    +
    +

    Do nothing. + +

    +
    +
    U+0000 +
    +
    U+0009 +
    +
    U+000A +
    +
    U+000D +
    +
    +

    Parse error. + +

    +
    +
    Otherwise +
    +
    + +
      + +
    1. +

      If c is not a URL code point and not + "%", parse error. + +

      +
    2. +
    3. +

      If c is "%" and remaining does + not start with two ASCII hex digits, parse error. + +

      +
    4. +
    5. + +

      Append c to url’s fragment. -

      Unfortunately not using percent-encoding is intentional as +

      +

      Unfortunately not using percent-encoding is intentional as implementations with majority market share exhibit this behavior. -

    -
    - +

    +
  2. +
+ + + + + + + + + -
  • Return url. - + +

  • +
  • +

    Return url. +

    +
  • -
    -

    To set the username given a url and +


    + + +

    To set the username given a url and username, run these steps: -

      -
    1. Set url’s username to the +

      +
        + +
      1. +

        Set url’s username to the empty string. -

      2. For each code point in username, - utf-8 percent encode it using the username encode set, and +

        +
      3. +
      4. +

        For each code point in username, + utf-8 percent encode it using the username encode set, and append the result to url’s - username. -

      + username. +

      +
    -

    To set the password given a url and + +

    To set the password given a url and password, run these steps: -

      -
    1. If password is the empty string, set url’s - password to null. +

      +
        + +
      1. +

        If password is the empty string, set url’s + password to null. -

      2. -

        Otherwise, run these substeps: +

        +
      3. +
      4. + +

        Otherwise, run these substeps: -

          -
        1. Set url’s password to +

          +
            + +
          1. +

            Set url’s password to the empty string. -

          2. For each code point in password, - utf-8 percent encode it using the password encode set, and +

            +
          3. +
          4. +

            For each code point in password, + utf-8 percent encode it using the password encode set, and append the result to url’s - password. -

          -
        + password. +

        +
      5. +
      + +
    -

    4.3. URL serializing

    -

    The URL serializer takes a -URL url, -optionally an exclude fragment flag, and then runs these steps: -

      -
    1. Let output be url’s - scheme and - ":" concatenated. +

      4.3. URL serializing

      -
    2. -

      If url’s relative flag is set: -

        -
      1. Append "//" to output. +

        The URL serializer takes a +URL url, +optionally an exclude fragment flag, and then runs these steps: + +

        +
          + +
        1. +

          Let output be url’s + scheme and + ":" concatenated. -

        2. -

          If url’s - username is not the empty string +

          +
        3. +
        4. + +

          If url’s relative flag is set: + +

          +
            + +
          1. +

            Append "//" to output. + +

            +
          2. +
          3. + +

            If url’s + username is not the empty string or url’s - password is non-null, run these + password is non-null, run these substeps: -

              -
            1. Append url’s - username to +

              +
                + +
              1. +

                Append url’s + username to output. -

              2. If url’s - password is non-null, append +

                +
              3. +
              4. +

                If url’s + password is non-null, append ":" concatenated with url’s - password to + password to output. -

              5. Append "@" to output. -

              - -
            2. Append url’s - host, - serialized, to +

              +
            3. +
            4. +

              Append "@" to output. +

              +
            5. +
            + + + +
          4. +
          5. +

            Append url’s + host, + serialized, to output. -

          6. If url’s port +

            +
          7. +
          8. +

            If url’s port is not the empty string, append ":" concatenated with - url’s port to + url’s port to output. -

          9. Append "/" concatenated with the strings in - url’s path +

            +
          10. +
          11. +

            Append "/" concatenated with the strings in + url’s path (including empty strings), separated from each other by "/" to output. -

          +

          +
        5. +
        + -
      2. Otherwise, if url’s relative flag is + +

      3. +
      4. +

        Otherwise, if url’s relative flag is unset, append url’s - scheme data to + scheme data to output. -

      5. If url’s query is non-null, +

        +
      6. +
      7. +

        If url’s query is non-null, append "?" concatenated with url’s - query to output. + query to output. -

      8. If the exclude fragment flag is unset and - url’s fragment is +

        +
      9. +
      10. +

        If the exclude fragment flag is unset and + url’s fragment is non-null, append "#" concatenated with - url’s fragment to + url’s fragment to output. -

      11. Return output. -

      +

      +
    3. +
    4. +

      Return output. +

      +
    -

    4.4. Origin

    +

    4.4. Origin

    -

    See origin’s definition in HTML for the -necessary background information. [HTML] -

    A URL’s origin is -the origin returned by running these steps, switching -on URL’s scheme: -

    -
    "blob" -
    -

    Let url be the result of - parsing - URL’s - scheme data. +

    See origin’s definition in HTML for the +necessary background information. [HTML] -

    If url is failure, return a new globally unique identifier. - Otherwise, return url’s origin. +

    +

    A URL’s origin is +the origin returned by running these steps, switching +on URL’s scheme: + +

    +
    + +
    "blob" +
    +
    + +

    Let url be the result of + parsing + URL’s + scheme data. + +

    +

    If url is failure, return a new globally unique identifier. + Otherwise, return url’s origin. -

    The origin of +

    +

    The origin of blob:https://whatwg.org/d0360e2f-caee-469f-9a2f-87d5b0456f6f is the tuple (https, whatwg.org, 443). -

    "ftp" -
    "gopher" -
    "http" -
    "https" -
    "ws" -
    "wss" -

    Return a tuple consisting of URL’s - scheme, its - host, and its default port if its - port is the empty string, and its - port otherwise. - -

    "file" -

    Unfortunate as it is, this is left as an exercise to the reader. When in doubt, +

    +
    +
    "ftp" +
    +
    "gopher" +
    +
    "http" +
    +
    "https" +
    +
    "ws" +
    +
    "wss" +
    +
    +

    Return a tuple consisting of URL’s + scheme, its + host, and its default port if its + port is the empty string, and its + port otherwise. + +

    +
    +
    "file" +
    +
    +

    Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new globally unique identifier. -

    Otherwise -

    Return a new globally unique identifier. -

    +

    +
    +
    Otherwise +
    +
    +

    Return a new globally unique identifier. +

    +
    + + +

    5. application/x-www-form-urlencoded

    -

    5. application/x-www-form-urlencoded

    -

    The application/x-www-form-urlencoded format is a simple way to +

    The application/x-www-form-urlencoded format is a simple way to encode name-value pairs in a byte sequence where all bytes are in the 0x00 to 0x7F range. -

    While this description makes -application/x-www-form-urlencoded sound dated — and really, it is — the +

    +

    While this description makes +application/x-www-form-urlencoded sound dated — and really, it is — the format is in widespread use due to its prevalence of HTML forms. -[HTML] +[HTML] + +

    +

    5.1. application/x-www-form-urlencoded parsing

    -

    5.1. application/x-www-form-urlencoded parsing

    -

    The features provided by the -application/x-www-form-urlencoded parser +

    The features provided by the +application/x-www-form-urlencoded parser are mainly relevant for server-oriented implementations. A browser-based implementation only needs what the -application/x-www-form-urlencoded string parser +application/x-www-form-urlencoded string parser requires. -

    The -application/x-www-form-urlencoded parser +

    +

    The +application/x-www-form-urlencoded parser takes a byte sequence input, optionally with an -encoding encoding override, +encoding encoding override, optionally with a use _charset_ flag, and optionally with an isindex flag, and then runs these steps: -

      -
    1. If encoding override is not given, set it to - utf-8. +

      +
        + +
      1. +

        If encoding override is not given, set it to + utf-8. -

      2. -

        If encoding override is not - utf-8 and input contains bytes +

        +
      3. +
      4. + +

        If encoding override is not + utf-8 and input contains bytes whose value is greater than 0x7F, return failure. -

        This can only happen if input was not - generated through the serializer or - URLSearchParams. +

        +

        This can only happen if input was not + generated through the serializer or + URLSearchParams. -

      5. Let sequences be the result of splitting +

        +
      6. +
      7. +

        Let sequences be the result of splitting input on `&`. -

      8. If the isindex flag is set and the first byte sequence in +

        +
      9. +
      10. +

        If the isindex flag is set and the first byte sequence in sequences does not contain a `=`, prepend `=` to the first byte sequence in sequences. -

      11. Let pairs be an empty list of name-value pairs where both name +

        +
      12. +
      13. +

        Let pairs be an empty list of name-value pairs where both name and value hold a byte sequence. -

      14. -

        For each byte sequence bytes in sequences, +

        +
      15. +
      16. + +

        For each byte sequence bytes in sequences, run these substeps: -

          -
        1. If bytes is the empty byte sequence, run these substeps for the +

          +
            + +
          1. +

            If bytes is the empty byte sequence, run these substeps for the next byte sequence. -

          2. If bytes contains a `=`, then let +

            +
          3. +
          4. +

            If bytes contains a `=`, then let name be the bytes from the start of bytes up to but excluding its first `=`, and let value be the bytes, if any, after the first `=` up to the end of @@ -1854,921 +3174,1487 @@

            name will be the empty byte sequence. If it is the last, then value will be the empty byte sequence. -
          5. Otherwise, let name have the value of bytes +

            +
          6. +
          7. +

            Otherwise, let name have the value of bytes and let value be the empty byte sequence. -

          8. Replace any `+` in name and +

            +
          9. +
          10. +

            Replace any `+` in name and value with 0x20. -

          11. -

            If use _charset_ flag is set, name is +

            +
          12. +
          13. + +

            If use _charset_ flag is set, name is `_charset_`, run these substeps: -

              -
            1. Let result be the result of - getting an encoding +

              +
                + +
              1. +

                Let result be the result of + getting an encoding for value, - decoded. + decoded. -

              2. If result is not failure, unset use _charset_ flag and +

                +
              3. +
              4. +

                If result is not failure, unset use _charset_ flag and set encoding override to result. -

              - -
            2. Add a pair consisting of name and +

              +
            3. +
            + + + +
          14. +
          15. +

            Add a pair consisting of name and value to pairs. -

          +

          +
        2. +
        + -
      17. Let output be an empty list of name-value pairs where both name + +

      18. +
      19. +

        Let output be an empty list of name-value pairs where both name and value hold a string. -

      20. For each name-value pair in pairs, append a name-value pair to +

        +
      21. +
      22. +

        For each name-value pair in pairs, append a name-value pair to output where the new name and value appended to output are the result of running encoding override’s - decoder on the - percent decoding of the name and value from + decoder on the + percent decoding of the name and value from pairs, respectively. -

      23. Return output. -

      +

      +
    2. +
    3. +

      Return output. +

      +
    -

    5.2. application/x-www-form-urlencoded serializing

    -

    The -application/x-www-form-urlencoded byte serializer +

    5.2. application/x-www-form-urlencoded serializing

    + + +

    The +application/x-www-form-urlencoded byte serializer takes a byte sequence input and then runs these steps: -

      -
    1. Let output be the empty string. -

    2. -

      For each byte in input, depending on +

      +
        + +
      1. +

        Let output be the empty string. +

        +
      2. +
      3. + +

        For each byte in input, depending on byte: -

        -
        0x20 -

        Append U+002B to output. - -

        0x2A -
        0x2D -
        0x2E -
        0x30 to 0x39 -
        0x41 to 0x5A -
        0x5F -
        0x61 to 0x7A -

        Append a code point whose value is byte to +

        +
        + +
        0x20 +
        +
        +

        Append U+002B to output. + +

        +
        +
        0x2A +
        +
        0x2D +
        +
        0x2E +
        +
        0x30 to 0x39 +
        +
        0x41 to 0x5A +
        +
        0x5F +
        +
        0x61 to 0x7A +
        +
        +

        Append a code point whose value is byte to output. -

        Otherwise -

        Append byte, - percent encoded, to +

        +
        +
        Otherwise +
        +
        +

        Append byte, + percent encoded, to output. -

        -
      4. Return output. -

      +

      + + + + +
    3. +
    4. +

      Return output. +

      +
    -

    The -application/x-www-form-urlencoded serializer + +

    The +application/x-www-form-urlencoded serializer takes a list of name-value pairs pairs, optionally with an -encoding +encoding encoding override, and then runs these steps: -

      -
    1. If encoding override is not given, set it to - utf-8. +

      +
        + +
      1. +

        If encoding override is not given, set it to + utf-8. -

      2. Let output be the empty string. +

        +
      3. +
      4. +

        Let output be the empty string. -

      5. -

        For each pair in pairs, run +

        +
      6. +
      7. + +

        For each pair in pairs, run these substeps: -

          -
        1. Let outputPair be a copy of pair. - -

        2. Replace outputPair’s name and value with the result of running - encode on them using +

          +
            + +
          1. +

            Let outputPair be a copy of pair. + +

            +
          2. +
          3. +

            Replace outputPair’s name and value with the result of running + encode on them using encoding override, respectively. -

          4. Replace outputPair’s name and value with their - serialization. +

            +
          5. +
          6. +

            Replace outputPair’s name and value with their + serialization. -

          7. If pair is not the first pair in pairs, append +

            +
          8. +
          9. +

            If pair is not the first pair in pairs, append "&" to output. -

          10. Append outputPair’s name, followed by "=", +

            +
          11. +
          12. +

            Append outputPair’s name, followed by "=", followed by outputPair’s value to output. -

          +

          +
        3. +
        + + + +
      8. +
      9. Return output. +
      -
    2. Return output. -
    -

    5.3. Hooks

    +

    5.3. Hooks

    -

    The -application/x-www-form-urlencoded string parser + +

    The +application/x-www-form-urlencoded string parser takes a string input, -utf-8 encodes it, and then +utf-8 encodes it, and then returns the result of -application/x-www-form-urlencoded parsing +application/x-www-form-urlencoded parsing it. -

    6. API

    +

    +

    6. API

    + -
    [Constructor(USVString url, optional USVString base = "about:blank"), Exposed=(Window,Worker)]
    -interface URL {
    -  static USVString domainToASCII(USVString domain);
    -  static USVString domainToUnicode(USVString domain);
    +      
    [Constructor(USVString url, optional USVString base = "about:blank"), Exposed=(Window,Worker)]
    +interface URL {
    +  static USVString domainToASCII(USVString domain);
    +  static USVString domainToUnicode(USVString domain);
     };
    -URL implements URLUtils;
    +URL implements URLUtils;
     
     [NoInterfaceObject,
      Exposed=(Window,Worker)]
    -interface URLUtils {
    -  stringifier attribute USVString href;
    -  readonly attribute USVString origin;
    -
    -           attribute USVString protocol;
    -           attribute USVString username;
    -           attribute USVString password;
    -           attribute USVString host;
    -           attribute USVString hostname;
    -           attribute USVString port;
    -           attribute USVString pathname;
    -           attribute USVString search;
    -           attribute URLSearchParams searchParams;
    -           attribute USVString hash;
    +interface URLUtils {
    +  stringifier attribute USVString href;
    +  readonly attribute USVString origin;
    +
    +           attribute USVString protocol;
    +           attribute USVString username;
    +           attribute USVString password;
    +           attribute USVString host;
    +           attribute USVString hostname;
    +           attribute USVString port;
    +           attribute USVString pathname;
    +           attribute USVString search;
    +           attribute URLSearchParams searchParams;
    +           attribute USVString hash;
     };
     
     [NoInterfaceObject,
      Exposed=(Window,Worker)]
    -interface URLUtilsReadOnly {
    -  stringifier readonly attribute USVString href;
    -  readonly attribute USVString origin;
    -
    -  readonly attribute USVString protocol;
    -  readonly attribute USVString host;
    -  readonly attribute USVString hostname;
    -  readonly attribute USVString port;
    -  readonly attribute USVString pathname;
    -  readonly attribute USVString search;
    -  readonly attribute USVString hash;
    +interface URLUtilsReadOnly {
    +  stringifier readonly attribute USVString href;
    +  readonly attribute USVString origin;
    +
    +  readonly attribute USVString protocol;
    +  readonly attribute USVString host;
    +  readonly attribute USVString hostname;
    +  readonly attribute USVString port;
    +  readonly attribute USVString pathname;
    +  readonly attribute USVString search;
    +  readonly attribute USVString hash;
     };
    -

    Except where different objects implementing URLUtilsReadOnly are identical -to objects implementing URLUtils. -

    Since all members are readonly and certain members from -URLUtils are not exposed a number of potential optimizations is possible -compared to objects implementing URLUtils. These are left as an exercise to +

    Except where different objects implementing URLUtilsReadOnly are identical +to objects implementing URLUtils. + +

    +

    Since all members are readonly and certain members from +URLUtils are not exposed a number of potential optimizations is possible +compared to objects implementing URLUtils. These are left as an exercise to the reader.

    -

    Specifications defining objects implementing URLUtils or -URLUtilsReadOnly must define a -get the base algorithm, which must return the -appropriate base URL for the object. -

    Specifications defining objects implementing URLUtils may -define update steps to make it possible for an +

    Specifications defining objects implementing URLUtils or +URLUtilsReadOnly must define a +get the base algorithm, which must return the +appropriate base URL for the object. + +

    +

    Specifications defining objects implementing URLUtils may +define update steps to make it possible for an underlying string (such as an -attribute value) -to be updated. The update steps are passed a string +attribute value) +to be updated. The update steps are passed a string value for this purpose. -

    An object implementing URLUtils or URLUtilsReadOnly has an -associated input (a string), -query encoding -(an encoding), -query object -(a URLSearchParams object or null), and a -url (a URL or null). - -

    Unless stated otherwise, query encoding is -utf-8 and -query object is null. The others follow -from the set the input algorithm.

    - -

    The associated -query encoding is a legacy -concept only relevant for HTML. -[HTML] - -

    Specifications defining objects implementing URLUtils or -URLUtilsReadOnly must use the -set the input algorithms to set -input, url, and -query object. To -set the input given input -and optionally a url, run these steps: - -

      -
    1. If url is given, set url - to url and input to - input. +

      +

      An object implementing URLUtils or URLUtilsReadOnly has an +associated input (a string), +query encoding +(an encoding), +query object +(a URLSearchParams object or null), and a +url (a URL or null). -

    2. -

      Otherwise, run these substeps: +

      +

      Unless stated otherwise, query encoding is +utf-8 and +query object is null. The others follow +from the set the input algorithm.

      -
        -
      1. Set url to null. -

      2. If input is null, set - input to the empty string. +

        The associated +query encoding is a legacy +concept only relevant for HTML. +[HTML] -

      3. -

        Otherwise, run these subsubsteps: +

        +

        Specifications defining objects implementing URLUtils or +URLUtilsReadOnly must use the +set the input algorithms to set +input, url, and +query object. To +set the input given input +and optionally a url, run these steps: -

          -
        1. Set input to input. +

          +
            + +
          1. +

            If url is given, set url + to url and input to + input. -

          2. Let url be the result of running the - URL parser on - input with - base URL being the result of running - get the base and - query encoding as +

            +
          3. +
          4. + +

            Otherwise, run these substeps: + +

            +
              + +
            1. +

              Set url to null. + +

              +
            2. +
            3. +

              If input is null, set + input to the empty string. + +

              +
            4. +
            5. + +

              Otherwise, run these subsubsteps: + +

              +
                + +
              1. +

                Set input to input. + +

                +
              2. +
              3. +

                Let url be the result of running the + URL parser on + input with + base URL being the result of running + get the base and + query encoding as encoding override. -

              4. If url is not failure, set - url to url. -

              -
            +

            +
          5. +
          6. +

            If url is not failure, set + url to url. +

            +
          7. +
          + + +
        2. +
        + -
      4. Let query be url’s - query if url + +

      5. +
      6. +

        Let query be url’s + query if url is non-null, and the empty string otherwise. -

      7. If query object is null, set - query object to a - new URLSearchParams object +

        +
      8. +
      9. +

        If query object is null, set + query object to a + new URLSearchParams object using query, and then append the - context object to - query object’s list of - url objects. + context object to + query object’s list of + url objects. + +

        +
      10. +
      11. +

        Otherwise, set query object’s + list to the result of + parsing query. +

        +
      -
    3. Otherwise, set query object’s - list to the result of - parsing query. -

    -

    To run the pre-update steps for an object implementing -URLUtils, optionally given a value, run these steps: +

    To run the pre-update steps for an object implementing +URLUtils, optionally given a value, run these steps: -

      -
    1. If value is not given, let value be the result - of serializing the associated - url. +

      +
        + +
      1. +

        If value is not given, let value be the result + of serializing the associated + url. -

      2. Run the update steps with +

        +
      3. +
      4. +

        Run the update steps with value. -

      +

      +
    -

    6.1. Constructors

    -

    The -URL(url, base) +

    6.1. Constructors

    + + +

    The +URL(url, base) constructor, when invoked, must run these steps: -

      -
    1. Let parsedBase be the result of running the - basic URL parser on base. +

      +
        + +
      1. +

        Let parsedBase be the result of running the + basic URL parser on base. -

      2. If parsedBase is failure, - throw a TypeError exception. +

        +
      3. +
      4. +

        If parsedBase is failure, + throw a TypeError exception. -

      5. Set parsedURL to the result of running the - basic URL parser on url +

        +
      6. +
      7. +

        Set parsedURL to the result of running the + basic URL parser on url with parsedBase. -

      8. If parsedURL is failure, - throw a TypeError exception. +

        +
      9. +
      10. +

        If parsedURL is failure, + throw a TypeError exception. -

      11. Let result be a new URL object. +

        +
      12. +
      13. +

        Let result be a new URL object. -

      14. Let result’s - get the base return +

        +
      15. +
      16. +

        Let result’s + get the base return parsedBase. -

      17. -

        Run result’s - set the input given the empty string +

        +
      18. +
      19. + +

        Run result’s + set the input given the empty string and parsedURL. -

        A URL object’s - input is never exposed. +

        +

        A URL object’s + input is never exposed. + +

        +
      20. +
      21. +

        Return result. +

        +
      -
    2. Return result. -

    -
    -

    To Basic URL parse a string into a - URL without using a - base URL, invoke the constructor with a single +

    + +

    To Basic URL parse a string into a + URL without using a + base URL, invoke the constructor with a single argument: -

    var input = "https://example.org/💩",    url = new URL(input)
    + 

    +
    var input = "https://example.org/💩",    url = new URL(input)
     url.pathname // "/%F0%9F%92%A9"
    -

    Alternatively you can use the base URL of a - document through - baseURI: + +

    Alternatively you can use the base URL of a + document through + baseURI: -

    var input = "/💩",    url = new URL(input, document.baseURI)
    + 

    +
    var input = "/💩",    url = new URL(input, document.baseURI)
     url.href // "https://url.spec.whatwg.org/%F0%9F%92%A9"
    -

    6.2. URL statics

    -

    The -domainToASCII(domain) +

    6.2. URL statics

    + + +

    The +domainToASCII(domain) static method, when invoked, must run these steps: -

      -
    1. Let asciiDomain be the result of - host parsing domain. +

      +
        + +
      1. +

        Let asciiDomain be the result of + host parsing domain. -

      2. If asciiDomain is an IPv6 address +

        +
      3. +
      4. +

        If asciiDomain is an IPv6 address or failure, return the empty string. -

      5. Return asciiDomain. -

      +

      +
    2. +
    3. +

      Return asciiDomain. +

      +
    + -

    The -domainToUnicode(domain) +

    The +domainToUnicode(domain) static method, when invoked, must run these steps: -

      -
    1. Let unicodeDomain be the result of - host parsing domain with the +

      +
        + +
      1. +

        Let unicodeDomain be the result of + host parsing domain with the Unicode flag set. -

      2. If unicodeDomain is an - IPv6 address or failure, return the empty string. +

        +
      3. +
      4. +

        If unicodeDomain is an + IPv6 address or failure, return the empty string. + +

        +
      5. +
      6. +

        Return unicodeDomain. +

        +
      -
    2. Return unicodeDomain. -

    -

    Add domainToUI() which follows the UA conventions for when to use the Unicode +

    Add domainToUI() which follows the UA conventions for when to use the Unicode representation? -

    6.3. URLUtils and URLUtilsReadOnly members

    +

    +

    6.3. URLUtils and URLUtilsReadOnly members

    + -

    The URLUtils and URLUtilsReadOnly interfaces are +

    The URLUtils and URLUtilsReadOnly interfaces are not exposed on the global object. They are meant to augment other interfaces, such as -URL. +URL. -

    The href attribute’s getter must run +

    +

    The href attribute’s getter must run these steps: -

      -
    1. If url is null, return - input. - -

    2. Return the serialization - of url. -

    - -

    The href attribute’s setter must run these steps: +

    +
      + +
    1. +

      If url is null, return + input. -

        -
      1. Let input be the given value. +

        +
      2. +
      3. +

        Return the serialization + of url. +

        +
      -
    2. -

      If the context object is a - URL object, run these substeps: -

        -
      1. Let parsedURL be the result of running the - basic URL parser on input - with base URL being the result of running - get the base. +

        The href attribute’s setter must run these steps: -

      2. If parsedURL is failure, - throw a TypeError exception. +

        +
          + +
        1. +

          Let input be the given value. -

        2. -

          Run set the input given the empty +

          +
        3. +
        4. + +

          If the context object is a + URL object, run these substeps: + +

          +
            + +
          1. +

            Let parsedURL be the result of running the + basic URL parser on input + with base URL being the result of running + get the base. + +

            +
          2. +
          3. +

            If parsedURL is failure, + throw a TypeError exception. + +

            +
          4. +
          5. + +

            Run set the input given the empty string and parsedURL. -

            A URL object’s - input is never exposed. -

          +

          +

          A URL object’s + input is never exposed. +

          +
        5. +
        + -
      3. -

        Otherwise, run these substeps: + +

      4. +
      5. + +

        Otherwise, run these substeps: -

          -
        1. Run the set the input +

          +
            + +
          1. +

            Run the set the input algorithm for input. -

          2. Run the pre-update steps with the input. -

          +

          +
        2. +
        3. +

          Run the pre-update steps with the input. +

          +
        4. +
        + -
        -

        This means that if the href attribute is set to - value that would cause the URL parser to return + +

        + +

        This means that if the href attribute is set to + value that would cause the URL parser to return failure, that value is still passed through unchanged. This is one of those unfortunate legacy incidents. -

        var a = document.createElement("a"),    input = "https://test:test/" // invalid port makes the parser return failure
        +   

        +
        var a = document.createElement("a"),    input = "https://test:test/" // invalid port makes the parser return failure
         a.href = test
         a.href === test // true
        -
        -
      + + +
    + -

    The origin attribute’s getter must + + + +

    The origin attribute’s getter must run these steps: -

      -
    1. If url is null, return the empty +

      +
        + +
      1. +

        If url is null, return the empty string. -

      2. Return the - Unicode serialization - of url’s origin. - [HTML] -

      +

      +
    2. +
    3. +

      Return the + Unicode serialization + of url’s origin. + [HTML] +

      +
    + -

    It returns the Unicode rather than the ASCII serialization for +

    It returns the Unicode rather than the ASCII serialization for compatibility with HTML’s MessageEvent feature. -[HTML] +[HTML] -

    The protocol attribute’s getter +

    +

    The protocol attribute’s getter must run these steps: -

      -
    1. If url is null, return +

      +
        + +
      1. +

        If url is null, return ":". -

      2. Return scheme and +

        +
      3. +
      4. +

        Return scheme and ":" concatenated. -

      +

      +
    -

    The protocol attribute’s setter must + +

    The protocol attribute’s setter must run these steps: -

      -
    1. If url is null, terminate +

      +
        + +
      1. +

        If url is null, terminate these steps. -

      2. Basic URL parse the given value and +

        +
      3. +
      4. +

        Basic URL parse the given value and ":" concatenated with - url as url and - scheme start state as state override. + url as url and + scheme start state as state override. + +

        +
      5. +
      6. +

        Run the pre-update steps. +

        +
      -
    2. Run the pre-update steps. -

    -

    The username attribute’s getter +

    The username attribute’s getter must run these steps: -

      -
    1. If url is null, return the +

      +
        + +
      1. +

        If url is null, return the empty string. -

      2. Return username. -

      +

      +
    2. +
    3. +

      Return username. +

      +
    + -

    The username attribute’s setter must +

    The username attribute’s setter must run these steps: -

      -
    1. If url is null, or its - relative flag is unset, terminate these steps. +

      +
        + +
      1. +

        If url is null, or its + relative flag is unset, terminate these steps. -

      2. Set the username given url +

        +
      3. +
      4. +

        Set the username given url and the given value. -

      5. Run the pre-update steps. -

      +

      +
    2. +
    3. +

      Run the pre-update steps. +

      +
    + -

    The password attribute’s getter +

    The password attribute’s getter must run these steps: -

      -
    1. If url is null or its - password is null, return the empty +

      +
        + +
      1. +

        If url is null or its + password is null, return the empty string. -

      2. Return password. -

      +

      +
    2. +
    3. +

      Return password. +

      +
    + -

    The password attribute’s setter must +

    The password attribute’s setter must run these steps: -

      -
    1. If url is null, or its - relative flag is unset, terminate these steps. +

      +
        + +
      1. +

        If url is null, or its + relative flag is unset, terminate these steps. -

      2. Set the password given url +

        +
      3. +
      4. +

        Set the password given url and the given value. -

      5. Run the pre-update steps. -

      +

      +
    2. +
    3. +

      Run the pre-update steps. +

      +
    -

    The host attribute’s getter must run + +

    The host attribute’s getter must run these steps: -

      -
    1. If url is null, return the +

      +
        + +
      1. +

        If url is null, return the empty string. -

      2. If port is the empty string, - return host, - serialized. +

        +
      3. +
      4. +

        If port is the empty string, + return host, + serialized. -

      5. Return host, - serialized, - ":", and port +

        +
      6. +
      7. +

        Return host, + serialized, + ":", and port concatenated. -

      +

      +
    -

    The host attribute’s setter must run these + +

    The host attribute’s setter must run these steps: -

      -
    1. If url is null, or its - relative flag is unset, terminate these steps. +

      +
        + +
      1. +

        If url is null, or its + relative flag is unset, terminate these steps. + +

        +
      2. +
      3. +

        Basic URL parse the given value with + url as url and + host state as state override. -

      4. Basic URL parse the given value with - url as url and - host state as state override. +

        +
      5. +
      6. +

        Run the pre-update steps. +

        +
      -
    2. Run the pre-update steps. -

    -

    The hostname attribute’s getter +

    The hostname attribute’s getter must run these steps: -

      -
    1. If url is null, return the +

      +
        + +
      1. +

        If url is null, return the empty string. -

      2. Return host, - serialized. -

      +

      +
    2. +
    3. +

      Return host, + serialized. +

      +
    + -

    The hostname attribute’s setter must +

    The hostname attribute’s setter must run these steps: -

      -
    1. If url is null, or its - relative flag is unset, terminate these steps. +

      +
        + +
      1. +

        If url is null, or its + relative flag is unset, terminate these steps. + +

        +
      2. +
      3. +

        Basic URL parse the given value with + url as url and + hostname state as state override. -

      4. Basic URL parse the given value with - url as url and - hostname state as state override. +

        +
      5. +
      6. +

        Run the pre-update steps. +

        +
      -
    2. Run the pre-update steps. -

    -

    The port attribute’s getter must run +

    The port attribute’s getter must run these steps: -

      -
    1. If url is null, return the +

      +
        + +
      1. +

        If url is null, return the empty string. -

      2. Return port. -

      +

      +
    2. +
    3. +

      Return port. +

      +
    + -

    The port attribute’s setter must run these steps: +

    The port attribute’s setter must run these steps: -

      -
    1. If url is null, its - relative flag is unset, or its - scheme is "file", +

      +
        + +
      1. +

        If url is null, its + relative flag is unset, or its + scheme is "file", terminate these steps. -

      2. Otherwise, Basic URL parse - the given value with url as url and - port state as state override. +

        +
      3. +
      4. +

        Otherwise, Basic URL parse + the given value with url as url and + port state as state override. + +

        +
      5. +
      6. +

        Run the pre-update steps. +

        +
      -
    2. Run the pre-update steps. -

    -

    The pathname attribute’s getter +

    The pathname attribute’s getter must run these steps: -

      -
    1. If url is null, return the +

      +
        + +
      1. +

        If url is null, return the empty string. -

      2. If the relative flag is unset, return - scheme data. +

        +
      3. +
      4. +

        If the relative flag is unset, return + scheme data. -

      5. Return "/" concatenated with the strings in - path (including empty strings), +

        +
      6. +
      7. +

        Return "/" concatenated with the strings in + path (including empty strings), separated from each other by "/". -

      +

      +
    -

    The pathname attribute’s setter must + +

    The pathname attribute’s setter must run these steps: -

      -
    1. If url is null, or its - relative flag is unset, terminate these steps. +

      +
        + +
      1. +

        If url is null, or its + relative flag is unset, terminate these steps. -

      2. Empty path. +

        +
      3. +
      4. +

        Empty path. -

      5. Basic URL parse the given value with - url as url and - relative path start state as state override. +

        +
      6. +
      7. +

        Basic URL parse the given value with + url as url and + relative path start state as state override. -

      8. Run the pre-update steps. -

      +

      +
    2. +
    3. +

      Run the pre-update steps. +

      +
    -

    The search attribute’s getter must + +

    The search attribute’s getter must run these steps: -

      -
    1. If url is null, or its - query is either null or +

      +
        + +
      1. +

        If url is null, or its + query is either null or the empty string, return the empty string. -

      2. Return "?" concatenated with - query. -

      +

      +
    2. +
    3. +

      Return "?" concatenated with + query. +

      +
    -

    The search attribute’s setter must run these steps: -

      -
    1. If url is null, terminate these steps. +

      The search attribute’s setter must run these steps: -

    2. If the given value is the empty string, set - query to null, empty - query object’s - list, run its - update steps, and terminate these +

      +
        + +
      1. +

        If url is null, terminate these steps. + +

        +
      2. +
      3. +

        If the given value is the empty string, set + query to null, empty + query object’s + list, run its + update steps, and terminate these steps. -

      4. Let input be the given value with a single leading +

        +
      5. +
      6. +

        Let input be the given value with a single leading "?" removed, if any. -

      7. Set query to the empty string. +

        +
      8. +
      9. +

        Set query to the empty string. -

      10. Basic URL parse input - with url as url, - query state as state override, and the - associated query encoding as +

        +
      11. +
      12. +

        Basic URL parse input + with url as url, + query state as state override, and the + associated query encoding as encoding override. -

      13. Set query object’s - list to the result of - parsing input. +

        +
      14. +
      15. +

        Set query object’s + list to the result of + parsing input. + +

        +
      16. +
      17. +

        Run query object’s + update steps. +

        +
      -
    3. Run query object’s - update steps. -

    -

    The update steps of -query object are run to ensure all -url objects remain synchronized. +

    The update steps of +query object are run to ensure all +url objects remain synchronized. -

    The searchParams attribute’s getter -must return the query object. +

    +

    The searchParams attribute’s getter +must return the query object. -

    The searchParams attribute’s setter must run +

    +

    The searchParams attribute’s setter must run these steps: -

      -
    1. Let object be the given value. +

      +
        + +
      1. +

        Let object be the given value. -

      2. Remove the context object from - query object’s list of - url objects. +

        +
      3. +
      4. +

        Remove the context object from + query object’s list of + url objects. -

      5. Append the context object to +

        +
      6. +
      7. +

        Append the context object to object’s list of - url objects. + url objects. -

      8. Set query object to +

        +
      9. +
      10. +

        Set query object to object. -

      11. Set query to the - serialization of the - query object’s - list. +

        +
      12. +
      13. +

        Set query to the + serialization of the + query object’s + list. -

      14. Run the pre-update steps. -

      +

      +
    2. +
    3. +

      Run the pre-update steps. +

      +
    -

    The hash attribute’s getter must run + +

    The hash attribute’s getter must run these steps: -

      -
    1. If url is null, or its - fragment is either null or +

      +
        + +
      1. +

        If url is null, or its + fragment is either null or the empty string, return the empty string. -

      2. Return "#" concatenated with - fragment. -

      +

      +
    2. +
    3. +

      Return "#" concatenated with + fragment. +

      +
    -

    The hash attribute’s setter must run these steps: -

      -
    1. If url is null, or its - scheme is +

      The hash attribute’s setter must run these steps: + +

      +
        + +
      1. +

        If url is null, or its + scheme is "javascript", terminate these steps. -

      2. If the given value is the empty string, set - fragment to null, run the - pre-update steps, and terminate these steps. +

        +
      3. +
      4. +

        If the given value is the empty string, set + fragment to null, run the + pre-update steps, and terminate these steps. -

      5. Let input be the given value with a single leading +

        +
      6. +
      7. +

        Let input be the given value with a single leading "#" removed, if any. -

      8. Set fragment to +

        +
      9. +
      10. +

        Set fragment to the empty string. -

      11. Basic URL parse input - with url as url and - fragment state as state override. +

        +
      12. +
      13. +

        Basic URL parse input + with url as url and + fragment state as state override. + +

        +
      14. +
      15. +

        Run the pre-update steps. +

        +
      -
    2. Run the pre-update steps. -

    -

    6.4. Interface URLSearchParams

    +

    6.4. Interface URLSearchParams

    -
    [Constructor(optional (USVString or URLSearchParams) init = ""), Exposed=(Window,Worker)]
    -interface URLSearchParams {
    -  void append(USVString name, USVString value);
    -  void delete(USVString name);
    -  USVString? get(USVString name);
    -  sequence<USVString> getAll(USVString name);
    -  boolean has(USVString name);
    -  void set(USVString name, USVString value);
    -  iterable<USVString, USVString>;
    -  stringifier;
    +
    +      
    [Constructor(optional (USVString or URLSearchParams) init = ""), Exposed=(Window,Worker)]
    +interface URLSearchParams {
    +  void append(USVString name, USVString value);
    +  void delete(USVString name);
    +  USVString? get(USVString name);
    +  sequence<USVString> getAll(USVString name);
    +  boolean has(USVString name);
    +  void set(USVString name, USVString value);
    +  iterable<USVString, USVString>;
    +  stringifier;
     };
    -

    A URLSearchParams object has an associated -list of name-value pairs, which is initially + +

    A URLSearchParams object has an associated +list of name-value pairs, which is initially empty. -

    A URLSearchParams object has an associated list of zero or more -url objects, which is initially empty. +

    +

    A URLSearchParams object has an associated list of zero or more +url objects, which is initially empty. -

    URLSearchParams objects always use -utf-8 as -encoding, despite the existence of +

    +

    URLSearchParams objects always use +utf-8 as +encoding, despite the existence of concepts such as -query encoding. This is to +query encoding. This is to encourage developers to migrate towards -utf-8, which they really ought to +utf-8, which they really ought to have done a long time ago now. -

    To create a -new URLSearchParams object, optionally +

    +

    To create a +new URLSearchParams object, optionally using init, run these steps: -

      -
    1. Let query be a new URLSearchParams object. +

      +
        + +
      1. +

        Let query be a new URLSearchParams object. -

      2. If init is the empty string or null, return +

        +
      3. +
      4. +

        If init is the empty string or null, return query. -

      5. If init is a string, - set query’s list to the - result of parsing +

        +
      6. +
      7. +

        If init is a string, + set query’s list to the + result of parsing init. -

      8. If init is a URLSearchParams object, set - query’s list to a copy - of init’s list. +

        +
      9. +
      10. +

        If init is a URLSearchParams object, set + query’s list to a copy + of init’s list. + +

        +
      11. +
      12. +

        Return query. +

        +
      -
    2. Return query. -

    -

    A URLSearchParams object’s -update steps are to run these steps for -each associated url object +

    A URLSearchParams object’s +update steps are to run these steps for +each associated url object urlObject, in order: -

      -
    1. Set urlObject’s url’s - query to the - serialization of - URLSearchParams object’s - list. +

      +
        + +
      1. +

        Set urlObject’s url’s + query to the + serialization of + URLSearchParams object’s + list. + +

        +
      2. +
      3. +

        Run urlObject’s pre-update steps. +

        +
      -
    2. Run urlObject’s pre-update steps. -

    -

    The -URLSearchParams(init) +

    The +URLSearchParams(init) constructor, when invoked, must return a -new URLSearchParams object +new URLSearchParams object using init if given. -

    The -append(name, value) +

    +

    The +append(name, value) method, when invoked, must run these steps: -

      -
    1. Append a new name-value pair whose name is name and - value is value, to list. +

      +
        + +
      1. +

        Append a new name-value pair whose name is name and + value is value, to list. -

      2. Run the update steps. -

      +

      +
    2. +
    3. +

      Run the update steps. +

      +
    -

    The -delete(name) + +

    The +delete(name) method, when invoked, must run these steps: -

      -
    1. Remove all name-value pairs whose name is name from - list. +

      +
        + +
      1. +

        Remove all name-value pairs whose name is name from + list. + +

        +
      2. +
      3. +

        Run the update steps. +

        +
      -
    2. Run the update steps. -

    -

    The -get(name) +

    The +get(name) method, when invoked, must return the value of the first name-value pair whose name is -name in list, and null if +name in list, and null if there is no such pair. -

    The -getAll(name) +

    +

    The +getAll(name) method, when invoked, must return the values of all name-value pairs whose name is -name, in list, +name, in list, in list order, and the empty sequence otherwise. -

    The -set(name, value) +

    +

    The +set(name, value) method, when invoked, must run these steps: -

      -
    1. If there are any name-value pairs whose name is name, in - list, set the value of the first such +

      +
        + +
      1. +

        If there are any name-value pairs whose name is name, in + list, set the value of the first such name-value pair to value and remove the others. -

      2. Otherwise, append a new name-value pair whose name is name and - value is value, to list. +

        +
      3. +
      4. +

        Otherwise, append a new name-value pair whose name is name and + value is value, to list. -

      5. Run the update steps. -

      +

      +
    2. +
    3. +

      Run the update steps. +

      +
    -

    The -has(name) + +

    The +has(name) method, when invoked, must return true if there is a name-value pair whose name is -name in list, and false +name in list, and false otherwise. -

    The value pairs to iterate over are the -list name-value pairs with the key being +

    +

    The value pairs to iterate over are the +list name-value pairs with the key being the name and the value the value. -

    The stringification behavior must return the -serialization of the -URLSearchParams object’s -list. +

    +

    The stringification behavior must return the +serialization of the +URLSearchParams object’s +list. + +

    +

    6.5. URL APIs elsewhere

    -

    6.5. URL APIs elsewhere

    -

    A standard that exposes URLs, should expose the -URL as a string (by serializing an internal -URL). A standard should not expose a URL using a -URL object. URL objects are -meant for URL manipulation. In IDL the USVString type should be used. +

    A standard that exposes URLs, should expose the +URL as a string (by serializing an internal +URL). A standard should not expose a URL using a +URL object. URL objects are +meant for URL manipulation. In IDL the USVString type should be used. -

    The higher-level notion here is that values are to be exposed as immutable +

    +

    The higher-level notion here is that values are to be exposed as immutable data structures. -

    If a standard decides to use a variant of the name "URL" for a feature it defines, it +

    +

    If a standard decides to use a variant of the name "URL" for a feature it defines, it should name such a feature "url" (i.e. lowercase and with an "l" at the end). Names such as "URL", "URI", and "IRI" should not be used. However, if the name is a compound, "URL" (i.e. uppercase) is preferred, e.g. "newURL" and "oldURL". -

    The EventSource and -HashChangeEvent interfaces in HTML are examples of -proper naming. [HTML] +

    +

    The EventSource and +HashChangeEvent interfaces in HTML are examples of +proper naming. [HTML] + +

    +

    Acknowledgments

    -

    Acknowledgments

    -

    There have been a lot of people that have helped make -URLs more interoperable over the years and +

    There have been a lot of people that have helped make +URLs more interoperable over the years and thereby furthered the goals of this standard. Likewise many people have helped making this standard what it is today. -

    With that, many thanks to +

    +

    With that, many thanks to Adam Barth, Albert Wiersch, Alexandre Morgaut, @@ -2814,80 +4700,337 @@

    Acknow 成瀬ゆい (Yui Naruse) for being awesome! -

    This standard is written by -Anne van Kesteren -(Mozilla, -annevk@annevk.nl) +

    +

    This standard is written by +Anne van Kesteren +(Mozilla, +annevk@annevk.nl) and -Sam Ruby -(IBM, -rubys@intertwingly.net). +Sam Ruby +(IBM, +rubys@intertwingly.net). -

    Per CC0, to +

    +

    Per CC0, to the extent possible under law, the editors have waived all copyright and related or neighboring rights to this work. -

    -

    Conformance

    +

    + + +

    Conformance

    + + -

    All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked +

    All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative. -

    The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", +

    +

    The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this specification are to be interpreted as described in RFC2119. For -readability, these words do not appear in all uppercase letters in this specification. [RFC2119] +readability, these words do not appear in all uppercase letters in this specification. [RFC2119] -

    Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end +

    +

    Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.) -

    References

    Normative References

    [DOM]
    Anne van Kesteren; Aryeh Gregor; Ms2ger. DOM. URL: https://dom.spec.whatwg.org/
    [ENCODING]
    Anne van Kesteren. Encoding. URL: https://encoding.spec.whatwg.org/
    [FILEAPI]
    Arun Ranganathan; Jonas Sicking. File API. URL: http://dev.w3.org/2006/webapi/FileAPI/
    [HTML]
    Ian Hickson. HTML. Living Standard. URL: https://html.spec.whatwg.org/
    [IDNA]
    Mark Davis; Michel Suignard. Unicode IDNA Compatibility Processing. URL: http://www.unicode.org/reports/tr46/
    [WEBIDL]
    Cameron McCormack; Jonas Sicking. Web IDL. URL: http://heycam.github.io/webidl/
    [rfc2119]
    S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
    [rfc4291]
    R. Hinden; S. Deering. IP Version 6 Addressing Architecture. February 2006. Draft Standard. URL: https://tools.ietf.org/html/rfc4291

    Informative References

    [rfc3986]
    T. Berners-Lee; R. Fielding; L. Masinter. Uniform Resource Identifier (URI): Generic Syntax. January 2005. Internet Standard. URL: https://tools.ietf.org/html/rfc3986
    [rfc3987]
    M. Duerst; M. Suignard. Internationalized Resource Identifiers (IRIs). January 2005. Proposed Standard. URL: https://tools.ietf.org/html/rfc3987
    [rfc5952]
    S. Kawamura; M. Kawashima. A Recommendation for IPv6 Address Text Representation. August 2010. Proposed Standard. URL: https://tools.ietf.org/html/rfc5952
    [rfc6454]
    A. Barth. The Web Origin Concept. December 2011. Proposed Standard. URL: https://tools.ietf.org/html/rfc6454

    Index

    IDL Index

    [Constructor(USVString url, optional USVString base = "about:blank"), Exposed=(Window,Worker)]
    -interface URL {
    -  static USVString domainToASCII(USVString domain);
    -  static USVString domainToUnicode(USVString domain);
    +

    +

    References

    +

    Normative References

    +
    +
    [DOM]
    +
    Anne van Kesteren; Aryeh Gregor; Ms2ger. DOM. URL: https://dom.spec.whatwg.org/
    +
    [ENCODING]
    +
    Anne van Kesteren. Encoding. URL: https://encoding.spec.whatwg.org/
    +
    [FILEAPI]
    +
    Arun Ranganathan; Jonas Sicking. File API. URL: http://dev.w3.org/2006/webapi/FileAPI/
    +
    [HTML]
    +
    Ian Hickson. HTML. Living Standard. URL: https://html.spec.whatwg.org/
    +
    [IDNA]
    +
    Mark Davis; Michel Suignard. Unicode IDNA Compatibility Processing. URL: http://www.unicode.org/reports/tr46/
    +
    [WEBIDL]
    +
    Cameron McCormack; Jonas Sicking. Web IDL. URL: http://heycam.github.io/webidl/
    +
    [rfc2119]
    +
    S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
    +
    [rfc4291]
    +
    R. Hinden; S. Deering. IP Version 6 Addressing Architecture. February 2006. Draft Standard. URL: https://tools.ietf.org/html/rfc4291
    +

    Informative References

    +
    +
    [rfc3986]
    +
    T. Berners-Lee; R. Fielding; L. Masinter. Uniform Resource Identifier (URI): Generic Syntax. January 2005. Internet Standard. URL: https://tools.ietf.org/html/rfc3986
    +
    [rfc3987]
    +
    M. Duerst; M. Suignard. Internationalized Resource Identifiers (IRIs). January 2005. Proposed Standard. URL: https://tools.ietf.org/html/rfc3987
    +
    [rfc5952]
    +
    S. Kawamura; M. Kawashima. A Recommendation for IPv6 Address Text Representation. August 2010. Proposed Standard. URL: https://tools.ietf.org/html/rfc5952
    +
    [rfc6454]
    +
    A. Barth. The Web Origin Concept. December 2011. Proposed Standard. URL: https://tools.ietf.org/html/rfc6454
    +

    Index

    +
      +
    • absolute-path-relative URL, 4.1
    • +
    • absolute URL, 4.1
    • +
    • append(), 6.4
    • +
    • append(name, value), 6.4
    • +
    • application/x-www-form-urlencoded, 5
    • +
    • ASCII alpha, 1
    • +
    • ASCII alphanumeric, 1
    • +
    • ASCII digits, 1
    • +
    • ASCII hex digits, 1
    • +
    • authority first slash state, 4.2
    • +
    • authority ignore slashes state, 4.2
    • +
    • authority second slash state, 4.2
    • +
    • authority state, 4.2
    • +
    • base, 6
    • +
    • base URL, 4
    • +
    • basic URL parser, 4.2
    • +
    • c, 1.1
    • +
    • default encode set, 2
    • +
    • default port, 4
    • +
    • delete(), 6.4
    • +
    • delete(name), 6.4
    • +
    • domain +
        +
      • definition of, 3
      • +
      • argument for URL/domainToASCII, 6
      • +
      • argument for URL/domainToUnicode, 6
      • +
      +
    • +
    • domain to ASCII, 3.1
    • +
    • domainToASCII(), 6.2
    • +
    • domainToASCII(domain), 6
    • +
    • domain to Unicode, 3.1
    • +
    • domainToUnicode(), 6.2
    • +
    • domainToUnicode(domain), 6
    • +
    • EOF code point, 1.1
    • +
    • file host state, 4.2
    • +
    • fragment state, 4.2
    • +
    • get(), 6.4
    • +
    • getAll(), 6.4
    • +
    • getAll(name), 6.4
    • +
    • get(name), 6.4
    • +
    • has(), 6.4
    • +
    • hash +
        +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • has(name), 6.4
    • +
    • host +
        +
      • definition of, 3
      • +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • hostname +
        +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • hostname state, 4.2
    • +
    • host parser, 3.3
    • +
    • host serializer, 3.4
    • +
    • host state, 4.2
    • +
    • href +
        +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • include credentials, 4
    • +
    • init, 6.4
    • +
    • IPv6, 3
    • +
    • IPv6 parser, 3.3
    • +
    • IPv6 parser Finale, 3.3
    • +
    • IPv6 parser IPv4, 3.3
    • +
    • IPv6 parser Main, 3.3
    • +
    • IPv6 piece, 3
    • +
    • IPv6 serializer, 3.4
    • +
    • name +
        +
      • argument for URLSearchParams/append, 6.4
      • +
      • argument for URLSearchParams/delete, 6.4
      • +
      • argument for URLSearchParams/get, 6.4
      • +
      • argument for URLSearchParams/getAll, 6.4
      • +
      • argument for URLSearchParams/has, 6.4
      • +
      • argument for URLSearchParams/set, 6.4
      • +
      +
    • +
    • no scheme state, 4.2
    • +
    • origin +
        +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • parse error, 1.1
    • +
    • password, 6.3
    • +
    • password encode set, 2
    • +
    • pathname +
        +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • path-relative URL, 4.1
    • +
    • path segment, 4.1
    • +
    • percent decode, 2
    • +
    • percent encode, 2
    • +
    • percent-encoded byte, 2
    • +
    • port +
        +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • port state, 4.2
    • +
    • pre-update steps, 6
    • +
    • protocol +
        +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • query state, 4.2
    • +
    • relative flag, 4
    • +
    • relative or authority state, 4.2
    • +
    • relative path start state, 4.2
    • +
    • relative path state, 4.2
    • +
    • relative scheme, 4
    • +
    • relative slash state, 4.2
    • +
    • relative state, 4.2
    • +
    • relative URL, 4.1
    • +
    • remaining, 1.1
    • +
    • scheme data state, 4.2
    • +
    • scheme-relative URL, 4.1
    • +
    • scheme start state, 4.2
    • +
    • scheme state, 4.2
    • +
    • search +
        +
      • attribute for URLUtilsReadOnly, 6
      • +
      • attribute for URLUtils, 6.3
      • +
      +
    • +
    • searchParams, 6.3
    • +
    • set(), 6.4
    • +
    • set(name, value), 6.4
    • +
    • set the password, 4.2
    • +
    • set the username, 4.2
    • +
    • simple encode set, 2
    • +
    • stringification behavior +
        +
      • dfn for URLUtils, 6
      • +
      • dfn for URLUtilsReadOnly, 6
      • +
      • dfn for URLSearchParams, 6.4
      • +
      +
    • +
    • URL +
        +
      • definition of, 4
      • +
      • (interface), 6
      • +
      +
    • +
    • URL(), 6.1
    • +
    • url, 6
    • +
    • URL code points, 4.1
    • +
    • urlencoded byte serializer, 5.2
    • +
    • urlencoded parser, 5.1
    • +
    • urlencoded serializer, 5.2
    • +
    • urlencoded string parser, 5.3
    • +
    • URL fragment, 4
    • +
    • URL host, 4
    • +
    • URL object, 4
    • +
    • URL origin, 4.4
    • +
    • URL parser, 4.2
    • +
    • URL password, 4
    • +
    • URL path, 4
    • +
    • URL port, 4
    • +
    • URL query, 4
    • +
    • URL scheme, 4
    • +
    • URL scheme data, 4
    • +
    • URLSearchParams, 6.4
    • +
    • URLSearchParams(), 6.4
    • +
    • URLSearchParams(init), 6.4
    • +
    • URLSearchParams list, 6.4
    • +
    • URLSearchParams new, 6.4
    • +
    • URLSearchParams update, 6.4
    • +
    • URLSearchParams URL object, 6.4
    • +
    • URL serializer, 4.3
    • +
    • URL units, 4.1
    • +
    • URL(url, base), 6
    • +
    • URL Userinfo, 4.1
    • +
    • URL username, 4
    • +
    • URLUtils, 6
    • +
    • URLUtils get the base, 6
    • +
    • URLUtils input, 6
    • +
    • URLUtils query encoding, 6
    • +
    • URLUtils query object, 6
    • +
    • URLUtilsReadOnly, 6
    • +
    • URLUtils set the input, 6
    • +
    • URLUtils update, 6
    • +
    • URLUtils URL, 6
    • +
    • username, 6.3
    • +
    • username encode set, 2
    • +
    • utf-8 percent encode, 2
    • +
    • valid domain, 3.2
    • +
    • value +
        +
      • argument for URLSearchParams/append, 6.4
      • +
      • argument for URLSearchParams/set, 6.4
      • +
      +
    +

    IDL Index

    +
    [Constructor(USVString url, optional USVString base = "about:blank"), Exposed=(Window,Worker)]
    +interface URL {
    +  static USVString domainToASCII(USVString domain);
    +  static USVString domainToUnicode(USVString domain);
     };
    -URL implements URLUtils;
    +URL implements URLUtils;
     
     [NoInterfaceObject,
      Exposed=(Window,Worker)]
    -interface URLUtils {
    -  stringifier attribute USVString href;
    -  readonly attribute USVString origin;
    -
    -           attribute USVString protocol;
    -           attribute USVString username;
    -           attribute USVString password;
    -           attribute USVString host;
    -           attribute USVString hostname;
    -           attribute USVString port;
    -           attribute USVString pathname;
    -           attribute USVString search;
    -           attribute URLSearchParams searchParams;
    -           attribute USVString hash;
    +interface URLUtils {
    +  stringifier attribute USVString href;
    +  readonly attribute USVString origin;
    +
    +           attribute USVString protocol;
    +           attribute USVString username;
    +           attribute USVString password;
    +           attribute USVString host;
    +           attribute USVString hostname;
    +           attribute USVString port;
    +           attribute USVString pathname;
    +           attribute USVString search;
    +           attribute URLSearchParams searchParams;
    +           attribute USVString hash;
     };
     
     [NoInterfaceObject,
      Exposed=(Window,Worker)]
    -interface URLUtilsReadOnly {
    -  stringifier readonly attribute USVString href;
    -  readonly attribute USVString origin;
    -
    -  readonly attribute USVString protocol;
    -  readonly attribute USVString host;
    -  readonly attribute USVString hostname;
    -  readonly attribute USVString port;
    -  readonly attribute USVString pathname;
    -  readonly attribute USVString search;
    -  readonly attribute USVString hash;
    +interface URLUtilsReadOnly {
    +  stringifier readonly attribute USVString href;
    +  readonly attribute USVString origin;
    +
    +  readonly attribute USVString protocol;
    +  readonly attribute USVString host;
    +  readonly attribute USVString hostname;
    +  readonly attribute USVString port;
    +  readonly attribute USVString pathname;
    +  readonly attribute USVString search;
    +  readonly attribute USVString hash;
     };
    -[Constructor(optional (USVString or URLSearchParams) init = ""), Exposed=(Window,Worker)]
    -interface URLSearchParams {
    -  void append(USVString name, USVString value);
    -  void delete(USVString name);
    -  USVString? get(USVString name);
    -  sequence<USVString> getAll(USVString name);
    -  boolean has(USVString name);
    -  void set(USVString name, USVString value);
    -  iterable<USVString, USVString>;
    -  stringifier;
    +[Constructor(optional (USVString or URLSearchParams) init = ""), Exposed=(Window,Worker)]
    +interface URLSearchParams {
    +  void append(USVString name, USVString value);
    +  void delete(USVString name);
    +  USVString? get(USVString name);
    +  sequence<USVString> getAll(USVString name);
    +  boolean has(USVString name);
    +  void set(USVString name, USVString value);
    +  iterable<USVString, USVString>;
    +  stringifier;
     };
    -
    \ No newline at end of file +
    + + \ No newline at end of file