@@ -152,10 +152,6 @@ export function init({ groups }) {
152152 tt ( Email , tk . DOT , EmailDomainDot ) ;
153153 tt ( Email , tk . HYPHEN , EmailDomainHyphen ) ;
154154
155- // Final possible email states
156- const EmailColon = tt ( Email , tk . COLON ) ; // URL followed by colon (potential port number here)
157- /*const EmailColonPort = */ ta ( EmailColon , groups . numeric , mtk . Email ) ; // URL followed by colon and port number
158-
159155 // Account for dots and hyphens. Hyphens are usually parts of domain names
160156 // (but not TLDs)
161157 const DomainHyphen = tt ( Domain , tk . HYPHEN ) ; // domain followed by hyphen
@@ -236,17 +232,19 @@ export function init({ groups }) {
236232 // Continue not accepting for open brackets
237233 tt ( UrlNonaccept , OPEN , UrlOpen ) ;
238234
239- // Closing bracket component. This character WILL be included in the URL
240- tt ( UrlOpen , CLOSE , Url ) ;
241-
242- // URL that beings with an opening bracket, followed by a symbols.
235+ // URL that begins with an opening bracket, followed by a symbols.
243236 // Note that the final state can still be `UrlOpen` (if the URL has a
244237 // single opening bracket for some reason).
245238 const UrlOpenQ = makeState ( mtk . Url ) ;
246239 ta ( UrlOpen , qsAccepting , UrlOpenQ ) ;
247240
248241 const UrlOpenSyms = makeState ( ) ; // UrlOpen followed by some symbols it cannot end it
249- ta ( UrlOpen , qsNonAccepting ) ;
242+ ta ( UrlOpen , qsNonAccepting , UrlOpenSyms ) ;
243+
244+ // Closing bracket component. This character WILL be included in the URL.
245+ // Must come after qsNonAccepting (which includes all close-bracket tokens)
246+ // so that CLOSE -> Url wins over CLOSE -> UrlOpenSyms.
247+ tt ( UrlOpen , CLOSE , Url ) ;
250248
251249 // URL that begins with an opening bracket, followed by some symbols
252250 ta ( UrlOpenQ , qsAccepting , UrlOpenQ ) ;
0 commit comments