Skip to content

Commit

Permalink
fix: avoid url -> file -> url parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Feb 10, 2023
1 parent 8b7cb64 commit 955b875
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/astro/src/content/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand Down

0 comments on commit 955b875

Please sign in to comment.