From 8e7c45bfe0dd712cf045335f8ae2a8fa03146c27 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 17 Nov 2022 08:43:30 -0800 Subject: [PATCH] Fix app page check on windows (#43022) Ensures we check for backslashes as well when matching `/page`. Will investigate adding the app suite to windows CI in follow-up x-ref: https://github.com/vercel/next.js/pull/42996 Fixes: https://github.com/vercel/next.js/issues/43019 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) --- packages/next/server/lib/find-page-file.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/next/server/lib/find-page-file.ts b/packages/next/server/lib/find-page-file.ts index 0b573f475166a2d..bba2122f002c11b 100644 --- a/packages/next/server/lib/find-page-file.ts +++ b/packages/next/server/lib/find-page-file.ts @@ -66,7 +66,7 @@ export async function findPageFile( // Determine if the file is leaf node page file under layouts, // The filename should start with 'page' and end with one of the allowed extensions export function isLayoutsLeafPage(filePath: string, pageExtensions: string[]) { - return new RegExp(`(^page|/page)\\.(?:${pageExtensions.join('|')})$`).test( - filePath - ) + return new RegExp( + `(^page|[\\/]page)\\.(?:${pageExtensions.join('|')})$` + ).test(filePath) }