summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/hip-horses-count.md5
-rw-r--r--packages/db/src/core/integration/index.ts5
2 files changed, 9 insertions, 1 deletions
diff --git a/.changeset/hip-horses-count.md b/.changeset/hip-horses-count.md
new file mode 100644
index 000000000..a08a41c95
--- /dev/null
+++ b/.changeset/hip-horses-count.md
@@ -0,0 +1,5 @@
+---
+"@astrojs/db": patch
+---
+
+Fix Astro DB seed failing when project path contains spaces. This resolves by properly decoding URL pathnames that contain encoded spaces (%20) before passing them to Vite's ssrLoadModule.
diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts
index 36dc6b0f8..c6f58d2fd 100644
--- a/packages/db/src/core/integration/index.ts
+++ b/packages/db/src/core/integration/index.ts
@@ -197,7 +197,10 @@ async function executeSeedFile({
fileUrl: URL;
viteServer: ViteDevServer;
}) {
- const mod = await viteServer.ssrLoadModule(fileUrl.pathname);
+ // Use decodeURIComponent to handle paths with spaces correctly
+ // This ensures that %20 in the pathname is properly handled
+ const pathname = decodeURIComponent(fileUrl.pathname);
+ const mod = await viteServer.ssrLoadModule(pathname);
if (typeof mod.default !== 'function') {
throw new AstroDbError(EXEC_DEFAULT_EXPORT_ERROR(fileURLToPath(fileUrl)));
}