From 491e4d2218759f003217c029f2bf4289119a1644 Mon Sep 17 00:00:00 2001 From: Eric Park Date: Mon, 23 Dec 2024 21:16:57 +0900 Subject: [PATCH] fix: match index files only by using entire basename The previous code would cause file names like `index.xml.ts` to be treated as index files, when they aren't (the file basename excluding the extension `.ts` is `index.xml`, and `index` should be the index file). To match index files only, match the entire first half of the basename when splitting by the last occurrence of the period/file extension delimiter. Pedantically this might not be correct -- i.e. some file extensions actually span multiple delimiters, like index.tar.gz. But in that case it's not an index file as well, so I think this is fine. Fixes #12675 --- packages/astro/src/core/routing/manifest/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index d1f498432e728..aabdd4e63d76d 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -183,7 +183,7 @@ function createFileBasedRoutes( validateSegment(segment, file); const parts = getParts(segment, file); - const isIndex = isDir ? false : basename.startsWith('index.'); + const isIndex = isDir ? false : basename.substring(0, basename.lastIndexOf('.')) === "index"; const routeSuffix = basename.slice(basename.indexOf('.'), -ext.length); const isPage = validPageExtensions.has(ext);