diff --git a/spec.bs b/spec.bs index 9649b35..3287120 100644 --- a/spec.bs +++ b/spec.bs @@ -532,11 +532,8 @@ To parse a constructor string given a string |input|: 1. If the result of running [=is a hash prefix=] given |parser| is true, then run [=change state=] given |parser|, "`hash`" and 1. 1. Otherwise if the result of running [=is a search prefix=] given |parser| is true: 1. Run [=change state=] given |parser|, "`search`" and 1. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPattern/hash}}"] to the empty string. 1. Otherwise: 1. Run [=change state=] given |parser|, "`pathname`" and 0. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPattern/search}}"] to the empty string. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPattern/hash}}"] to the empty string. 1. Increment |parser|'s [=constructor string parser/token index=] by |parser|'s [=constructor string parser/token increment=]. 1. [=Continue=]. 1. If |parser|'s [=constructor string parser/state=] is "`authority`": @@ -564,14 +561,6 @@ To parse a constructor string given a string |input|:
"`init`"
1. If the result of running [=is a protocol suffix=] given |parser| is true: -

We found a protocol suffix, so this is an absolute URLPattern constructor string. Therefore initialize all component to the empty string. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/username}}"] to the empty string. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/password}}"] to the empty string. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/hostname}}"] to the empty string. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/port}}"] to the empty string. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/pathname}}"] to the empty string. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/search}}"] to the empty string. - 1. Set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/hash}}"] to the empty string. 1. Run [=rewind and set state=] given |parser| and "`protocol`".

"`protocol`"
@@ -579,7 +568,6 @@ To parse a constructor string given a string |input|: 1. If the result of running [=is a protocol suffix=] given |parser| is true: 1. Run [=compute protocol matches a special scheme flag=] given |parser|.

We need to eagerly compile the protocol component to determine if it matches any [=special schemes=]. If it does then certain special rules apply. It determines if the pathname defaults to a "`/`" and also whether we will look for the username, password, hostname, and port components. Authority slashes can also cause us to look for these components as well. Otherwise we treat this as an "opaque path URL" and go straight to the pathname component. - 1. If |parser|'s [=constructor string parser/protocol matches a special scheme flag=] is true, then set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/pathname}}"] to "`/`". 1. Let |next state| be "`pathname`". 1. Let |skip| be 1. 1. If the result of running [=next is authority slashes=] given |parser| is true: @@ -642,6 +630,9 @@ To parse a constructor string given a string |input|: 1. Increment |parser|'s [=constructor string parser/token index=] by |parser|'s [=constructor string parser/token increment=]. + 1. If |parser|'s [=constructor string parser/result=] [=map/contains=] "{{URLPatternInit/hostname}}" and not "{{URLPatternInit/port}}", then set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/port}}"] to the empty string. + +

This is special-cased because when an author does not specify a port, they usually intend the default port. If any port is acceptable, the author can specify it as a wildcard explicitly. For example, "`https://example.com/*`" should not match URLs beginning with "`https://example.com:8443/`", which is a different origin.
1. Return |parser|'s [=constructor string parser/result=]. @@ -649,6 +640,12 @@ To parse a constructor string given a string |input|: To change state given a [=constructor string parser=] |parser|, a [=constructor string parser/state=] |new state|, and a number |skip|: 1. If |parser|'s [=constructor string parser/state=] is not "`init`", not "`authority`", and not "`done`", then set |parser|'s [=constructor string parser/result=][|parser|'s [=constructor string parser/state=]] to the result of running [=make a component string=] given |parser|. + 1. If |parser|'s [=constructor string parser/state=] is not "`init`" and |new state| is not "`done`", then: + 1. It |parser|'s [=constructor string parser/state=] is "`protocol`", "`authority`", "`username`", or "`password`"; |new state| is "`port`", "`pathname`", "`search`", or "`hash`"; and |parser|'s [=constructor string parser/result=]["{{URLPatternInit/hostname}}"] does not [=map/exist=], then set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/hostname}}"] to the empty string. + 1. It |parser|'s [=constructor string parser/state=] is "`protocol`", "`authority`", "`username`", "`password`", "`hostname`", or "`port`"; |new state| is "`search`", or "`hash`"; and |parser|'s [=constructor string parser/result=]["{{URLPatternInit/pathname}}"] does not [=map/exist=], then: + 1. If |parser|'s [=constructor string parser/protocol matches a special scheme flag=] is true, then set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/pathname}}"] to "`/`". + 1. Otherwise, set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/pathname}}"] to the empty string. + 1. It |parser|'s [=constructor string parser/state=] is "`protocol`", "`authority`", "`username`", "`password`", "`hostname`", "`port`", or "`pathname`"; |new state| is "`hash`"; and |parser|'s [=constructor string parser/result=]["{{URLPatternInit/search}}"] does not [=map/exist=], then set |parser|'s [=constructor string parser/result=]["{{URLPatternInit/search}}"] to the empty string. 1. Set |parser|'s [=constructor string parser/state=] to |new state|. 1. Increment |parser|'s [=constructor string parser/token index=] by |skip|. 1. Set |parser|'s [=constructor string parser/component start=] to |parser|'s [=constructor string parser/token index=].