diff options
author | 2023-02-13 10:10:33 -0500 | |
---|---|---|
committer | 2023-02-13 10:10:33 -0500 | |
commit | baa2dbb3b5678b2bd56fb80df99d386f32e274b7 (patch) | |
tree | d61ed4948fcde35a11d6471e7ede8d0f8b203851 | |
parent | 2d72ea30ae6187bb5ed98c3b5e2d609d0f6835f9 (diff) | |
download | astro-baa2dbb3b5678b2bd56fb80df99d386f32e274b7.tar.gz astro-baa2dbb3b5678b2bd56fb80df99d386f32e274b7.tar.zst astro-baa2dbb3b5678b2bd56fb80df99d386f32e274b7.zip |
Fix `getEntryType` failure on spaces in file name (#6218)
* fix: avoid url -> file -> url parsing
* chore: changeset
-rw-r--r-- | .changeset/orange-sheep-deliver.md | 5 | ||||
-rw-r--r-- | packages/astro/src/content/utils.ts | 12 |
2 files changed, 10 insertions, 7 deletions
diff --git a/.changeset/orange-sheep-deliver.md b/.changeset/orange-sheep-deliver.md new file mode 100644 index 000000000..cf8ecf318 --- /dev/null +++ b/.changeset/orange-sheep-deliver.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix: internal content collection error on spaces in file name diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index afde00743..857da52ef 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -163,11 +163,10 @@ export function getEntryType( entryPath: string, paths: Pick<ContentPaths, 'config'> ): 'content' | 'config' | 'ignored' | 'unsupported' { - const { dir: rawDir, ext, base } = path.parse(entryPath); - const dir = appendForwardSlash(pathToFileURL(rawDir).href); - const fileUrl = new URL(base, dir); + const { ext, base } = path.parse(entryPath); + const fileUrl = pathToFileURL(entryPath); - if (hasUnderscoreInPath(fileUrl) || isOnIgnoreList(fileUrl)) { + if (hasUnderscoreInPath(fileUrl) || isOnIgnoreList(base)) { return 'ignored'; } else if ((contentFileExts as readonly string[]).includes(ext)) { return 'content'; @@ -178,9 +177,8 @@ export function getEntryType( } } -function isOnIgnoreList(fileUrl: URL) { - const { base } = path.parse(fileURLToPath(fileUrl)); - return ['.DS_Store'].includes(base); +function isOnIgnoreList(fileName: string) { + return ['.DS_Store'].includes(fileName); } function hasUnderscoreInPath(fileUrl: URL): boolean { |