File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change 11const DEFAULT_DELIMITER = "/" ;
22const NOOP_VALUE = ( value : string ) => value ;
3- const ID_CHAR = / ^ \p{ XID_Continue} $ / u;
3+ const ID_START = / ^ [ $ _ \p{ ID_Start} ] $ / u;
4+ const ID_CONTINUE = / ^ [ $ \u200c \u200d \p{ ID_Continue} ] $ / u;
45const DEBUG_URL = "https://git.new/pathToRegexpError" ;
56
67/**
@@ -144,12 +145,35 @@ function lexer(str: string) {
144145 if ( value === ":" ) {
145146 let name = "" ;
146147
147- while ( ID_CHAR . test ( chars [ ++ i ] ) ) {
148+ if ( ID_START . test ( chars [ ++ i ] ) ) {
148149 name += chars [ i ] ;
150+ while ( ID_CONTINUE . test ( chars [ ++ i ] ) ) {
151+ name += chars [ i ] ;
152+ }
153+ } else if ( chars [ i ] === '"' ) {
154+ let pos = i ;
155+
156+ while ( i < chars . length ) {
157+ if ( chars [ ++ i ] === '"' ) {
158+ i ++ ;
159+ pos = 0 ;
160+ break ;
161+ }
162+
163+ if ( chars [ i ] === "\\" ) {
164+ name += chars [ ++ i ] ;
165+ } else {
166+ name += chars [ i ] ;
167+ }
168+ }
169+
170+ if ( pos ) {
171+ throw new TypeError ( `Unterminated quote at ${ pos } : ${ DEBUG_URL } ` ) ;
172+ }
149173 }
150174
151175 if ( ! name ) {
152- throw new TypeError ( `Missing parameter name at ${ i } ` ) ;
176+ throw new TypeError ( `Missing parameter name at ${ i } : ${ DEBUG_URL } ` ) ;
153177 }
154178
155179 tokens . push ( { type : "NAME" , index : i , value : name } ) ;
You can’t perform that action at this time.
0 commit comments