File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 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 = []) => {
2222}
2323
2424const matchMiddleware = ( middleware , filePath ) =>
25- middleware . includes ( '' ) ||
25+ middleware ? .includes ( '' ) ||
2626 middleware ?. find (
2727 ( middlewarePath ) =>
2828 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', () => {
410410 }
411411 } )
412412
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+
413429 test ( 'stripLocale correctly strips matching locales' , ( ) => {
414430 const locales = [ 'en' , 'fr' , 'en-GB' ]
415431 const paths = [
You can’t perform that action at this time.
0 commit comments