Fix getEntryType
failure on spaces in file name (#6218)
* fix: avoid url -> file -> url parsing * chore: changeset
This commit is contained in:
parent
2d72ea30ae
commit
baa2dbb3b5
2 changed files with 10 additions and 7 deletions
5
.changeset/orange-sheep-deliver.md
Normal file
5
.changeset/orange-sheep-deliver.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix: internal content collection error on spaces in file name
|
|
@ -163,11 +163,10 @@ export function getEntryType(
|
||||||
entryPath: string,
|
entryPath: string,
|
||||||
paths: Pick<ContentPaths, 'config'>
|
paths: Pick<ContentPaths, 'config'>
|
||||||
): 'content' | 'config' | 'ignored' | 'unsupported' {
|
): 'content' | 'config' | 'ignored' | 'unsupported' {
|
||||||
const { dir: rawDir, ext, base } = path.parse(entryPath);
|
const { ext, base } = path.parse(entryPath);
|
||||||
const dir = appendForwardSlash(pathToFileURL(rawDir).href);
|
const fileUrl = pathToFileURL(entryPath);
|
||||||
const fileUrl = new URL(base, dir);
|
|
||||||
|
|
||||||
if (hasUnderscoreInPath(fileUrl) || isOnIgnoreList(fileUrl)) {
|
if (hasUnderscoreInPath(fileUrl) || isOnIgnoreList(base)) {
|
||||||
return 'ignored';
|
return 'ignored';
|
||||||
} else if ((contentFileExts as readonly string[]).includes(ext)) {
|
} else if ((contentFileExts as readonly string[]).includes(ext)) {
|
||||||
return 'content';
|
return 'content';
|
||||||
|
@ -178,9 +177,8 @@ export function getEntryType(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isOnIgnoreList(fileUrl: URL) {
|
function isOnIgnoreList(fileName: string) {
|
||||||
const { base } = path.parse(fileURLToPath(fileUrl));
|
return ['.DS_Store'].includes(fileName);
|
||||||
return ['.DS_Store'].includes(base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasUnderscoreInPath(fileUrl: URL): boolean {
|
function hasUnderscoreInPath(fileUrl: URL): boolean {
|
||||||
|
|
Loading…
Reference in a new issue