File tree 1 file changed +27
-3
lines changed
1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change 1
1
const DEFAULT_DELIMITER = "/" ;
2
2
const 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;
4
5
const DEBUG_URL = "https://git.new/pathToRegexpError" ;
5
6
6
7
/**
@@ -144,12 +145,35 @@ function lexer(str: string) {
144
145
if ( value === ":" ) {
145
146
let name = "" ;
146
147
147
- while ( ID_CHAR . test ( chars [ ++ i ] ) ) {
148
+ if ( ID_START . test ( chars [ ++ i ] ) ) {
148
149
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
+ }
149
173
}
150
174
151
175
if ( ! name ) {
152
- throw new TypeError ( `Missing parameter name at ${ i } ` ) ;
176
+ throw new TypeError ( `Missing parameter name at ${ i } : ${ DEBUG_URL } ` ) ;
153
177
}
154
178
155
179
tokens . push ( { type : "NAME" , index : i , value : name } ) ;
You can’t perform that action at this time.
0 commit comments