mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
fix: match index files only by using entire basename (#12815)
* 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 * Add changeset
This commit is contained in:
parent
fbac92f8bd
commit
3acc65444c
2 changed files with 6 additions and 1 deletions
5
.changeset/small-maps-give.md
Normal file
5
.changeset/small-maps-give.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Some non-index files that were incorrectly being treated as index files are now excluded
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue