diff options
author | 2025-03-03 08:57:51 -0600 | |
---|---|---|
committer | 2025-03-03 14:57:51 +0000 | |
commit | a001a75d6ec08378d607531dc73959bf0a9e079e (patch) | |
tree | 47a1f09673871d94e53c6168167dcedefeb164de | |
parent | 55ef4f574f08c9c8b9eaf073b45c59e10d4ee8e4 (diff) | |
download | astro-a001a75d6ec08378d607531dc73959bf0a9e079e.tar.gz astro-a001a75d6ec08378d607531dc73959bf0a9e079e.tar.zst astro-a001a75d6ec08378d607531dc73959bf0a9e079e.zip |
fix: resolve Astro DB seed failure with paths containing spaces (#13343)
-rw-r--r-- | .changeset/hip-horses-count.md | 5 | ||||
-rw-r--r-- | packages/db/src/core/integration/index.ts | 5 |
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))); } |