File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -234,25 +234,28 @@ export class SimplePathMatcher extends Serializable implements RequestMatcher {
234
234
235
235
export class RegexPathMatcher extends Serializable implements RequestMatcher {
236
236
readonly type = 'regex-path' ;
237
+
237
238
readonly regexSource : string ;
239
+ readonly regexFlags : string ;
238
240
239
241
constructor ( regex : RegExp ) {
240
242
super ( ) ;
241
243
this . regexSource = regex . source ;
244
+ this . regexFlags = regex . flags ;
242
245
}
243
246
244
247
matches ( request : OngoingRequest ) {
245
248
const absoluteUrl = normalizeUrl ( request . url ) ;
246
249
const urlPath = getPathFromAbsoluteUrl ( absoluteUrl ) ;
247
250
248
251
// Test the matcher against both the path alone & the full URL
249
- const urlMatcher = new RegExp ( this . regexSource ) ;
252
+ const urlMatcher = new RegExp ( this . regexSource , this . regexFlags ) ;
250
253
return urlMatcher . test ( absoluteUrl ) ||
251
254
urlMatcher . test ( urlPath ) ;
252
255
}
253
256
254
257
explain ( ) {
255
- return `matching /${ unescapeRegexp ( this . regexSource ) } /` ;
258
+ return `matching /${ unescapeRegexp ( this . regexSource ) } /${ this . regexFlags ?? '' } ` ;
256
259
}
257
260
258
261
}
You can’t perform that action at this time.
0 commit comments