fix(fc2c-i): router falls back to memory history when no window (vitest)

This commit is contained in:
2026-05-15 21:27:28 -04:00
parent 85d8b4b150
commit 5a4663fa3d
+7 -2
View File
@@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createRouter, createWebHistory, createMemoryHistory } from 'vue-router'
import PlaceholderView from './views/PlaceholderView.vue'
import SettingsView from './views/SettingsView.vue'
import GalleryView from './views/GalleryView.vue'
@@ -28,8 +28,13 @@ const routes = [
{ path: '/downloads', name: 'downloads', component: PlaceholderView, meta: { title: 'Downloads' } }
]
// Browser uses HTML5 history; non-browser (Vitest/SSR) falls back to memory
// history so the module is importable without `window`.
const history =
typeof window !== 'undefined' ? createWebHistory() : createMemoryHistory()
const router = createRouter({
history: createWebHistory(),
history,
routes
})