File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const stripLocale = (rawPath, locales = []) => {
22
22
}
23
23
24
24
const matchMiddleware = ( middleware , filePath ) =>
25
- middleware . includes ( '' ) ||
25
+ middleware ? .includes ( '' ) ||
26
26
middleware ?. find (
27
27
( middlewarePath ) =>
28
28
filePath === middlewarePath || filePath === `${ middlewarePath } .html` || filePath . startsWith ( `${ middlewarePath } /` ) ,
Original file line number Diff line number Diff line change @@ -410,6 +410,22 @@ describe('utility functions', () => {
410
410
}
411
411
} )
412
412
413
+ test ( 'middleware tester matches root middleware' , ( ) => {
414
+ const paths = [
415
+ 'middl' ,
416
+ '' ,
417
+ 'somethingelse' ,
418
+ 'another.html' ,
419
+ 'another/middle.html' ,
420
+ 'sub/anotherdirectory.html' ,
421
+ 'sub/directoryelse' ,
422
+ 'sub/directoryelse.html' ,
423
+ ]
424
+ for ( const path of paths ) {
425
+ expect ( matchMiddleware ( undefined , path ) ) . toBeFalsy ( )
426
+ }
427
+ } )
428
+
413
429
test ( 'stripLocale correctly strips matching locales' , ( ) => {
414
430
const locales = [ 'en' , 'fr' , 'en-GB' ]
415
431
const paths = [
You can’t perform that action at this time.
0 commit comments