summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Arsh <69170106+lilnasy@users.noreply.github.com> 2023-08-19 01:12:53 +0530
committerGravatar GitHub <noreply@github.com> 2023-08-18 15:42:53 -0400
commit04caa99c48ce604ca3b90302ff0df8dcdbeee650 (patch)
treed41b80664bc467af525b81bc5bdbadd6c7082287
parente3c030e5d3bef916bc5319327b0c978a355031e3 (diff)
downloadastro-04caa99c48ce604ca3b90302ff0df8dcdbeee650.tar.gz
astro-04caa99c48ce604ca3b90302ff0df8dcdbeee650.tar.zst
astro-04caa99c48ce604ca3b90302ff0df8dcdbeee650.zip
fix(data collections): normalize file paths for DataEntry.id (#8144)
* normalize file paths for DataEntry.id * add changeset
-rw-r--r--.changeset/twenty-mirrors-remember.md5
-rw-r--r--packages/astro/src/content/utils.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/twenty-mirrors-remember.md b/.changeset/twenty-mirrors-remember.md
new file mode 100644
index 000000000..4d758d420
--- /dev/null
+++ b/.changeset/twenty-mirrors-remember.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fixed an issue where data entries' id included backslashes instead of forward slashes on Windows.
diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts
index d273dc105..23a305426 100644
--- a/packages/astro/src/content/utils.ts
+++ b/packages/astro/src/content/utils.ts
@@ -209,7 +209,7 @@ export function getDataEntryId({
collection,
}: Pick<ContentPaths, 'contentDir'> & { entry: URL; collection: string }): string {
const relativePath = getRelativeEntryPath(entry, collection, contentDir);
- const withoutFileExt = relativePath.replace(new RegExp(path.extname(relativePath) + '$'), '');
+ const withoutFileExt = normalizePath(relativePath).replace(new RegExp(path.extname(relativePath) + '$'), '');
return withoutFileExt;
}