From cea4ff83d649d474358eb36fda146ef37e92c5b1 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Sat, 21 Jan 2017 17:44:04 +0100 Subject: [PATCH 1/2] Change path parsing for non-special URLs This allows paths to be empty for non-special URLs and also takes that into account when serializing. Tests: https://github.com/w3c/web-platform-tests/pull/4586. Fixes #212. --- url.bs | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/url.bs b/url.bs index 6696bd49..cd535745 100644 --- a/url.bs +++ b/url.bs @@ -837,6 +837,9 @@ null or a 16-bit unsigned integer that identifies a networking port. It is initi ASCII strings holding data, usually identifying a location in hierarchical form. It is initially the empty list. +

A special URL always has a +non-empty path. +

A URL's query is either null or an ASCII string holding data. It is initially null. @@ -1512,8 +1515,8 @@ string input, optionally with a base URL base, opti

  1. -

    If either c is "/", or url is special and - c is "\", run these substeps: +

    If url is special and c is "/" or "\", + then:

    1. If c is "\", syntax violation. @@ -1521,6 +1524,9 @@ string input, optionally with a base URL base, opti

    2. Set state to special authority ignore slashes state.

    +
  2. Otherwise, if c is "/", then set state to + authority state. +

  3. Otherwise, set url's username to base's username, @@ -1877,12 +1883,27 @@ string input, optionally with a base URL base, opti

    path start state
      -
    1. If url is special and c is "\", - syntax violation. +

    2. +

      If url is special, then: -

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

        +
      1. If c is "\", syntax violation. + +

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

      + +
    4. Otherwise, if state override is not given and c is "?", + then set url's query to the empty string and state to + query state. + +

    5. Otherwise, if state override is not given and c is "#", + then set url's fragment to the empty string and state to + fragment state. + +

    6. Otherwise, if c is not EOF code point, then: set state to + path state and if c is not "/", then decrease pointer by + one.

    path state @@ -2141,9 +2162,8 @@ then runs these steps:
  4. If url's cannot-be-a-base-URL flag is set, append the first string in url's path to output. -

  5. Otherwise, append "/", followed by the strings in url's - path (including empty strings), if any, separated from each other by - "/", to output. +

  6. Otherwise, then for each string in url's path, + append "/" followed by the string to output.

  7. If url's query is non-null, append "?", followed by url's query, to @@ -2692,6 +2712,9 @@ the setter to always "reset" both.

  8. If context object's url's cannot-be-a-base-URL flag is set, then return context object's url's path[0]. +

  9. If context object's url's path + is empty, then return the empty string. +

  10. Return "/", followed by the strings in context object's url's path (including empty strings), if any, separated from each other by "/". From 97bf5699cee9dfa56a90f8f0fc884569bb4cecb4 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 27 Jan 2017 15:47:42 +0100 Subject: [PATCH 2/2] style nit --- url.bs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/url.bs b/url.bs index cd535745..4fbff84d 100644 --- a/url.bs +++ b/url.bs @@ -1889,8 +1889,10 @@ string input, optionally with a base URL base, opti

    1. If c is "\", syntax violation. -

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

    3. Set state to path state. + +

    4. If c is neither "/" nor "\", then decrease + pointer by one.

  11. Otherwise, if state override is not given and c is "?",