Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle cleanUrls with subfolders when using a trailing slash #1575

Merged
11 changes: 6 additions & 5 deletions src/client/app/utils.ts
Expand Up @@ -22,10 +22,7 @@ export function withBase(path: string) {
export function pathToFile(path: string): string {
let pagePath = path.replace(/\.html$/, '')
pagePath = decodeURIComponent(pagePath)
if (pagePath.endsWith('/')) {
pagePath += 'index'
}

pagePath = pagePath.replace(/\/$/, '/index') // /foo/ -> /foo/index
if (import.meta.env.DEV) {
// always force re-fetch content in dev
pagePath += `.md?t=${Date.now()}`
Expand All @@ -41,7 +38,11 @@ export function pathToFile(path: string): string {
) + '.md'
// client production build needs to account for page hash, which is
// injected directly in the page's html
const pageHash = __VP_HASH_MAP__[pagePath.toLowerCase()]
let pageHash = __VP_HASH_MAP__[pagePath.toLowerCase()]
if (!pageHash && pagePath.endsWith('_index.md')) {
pagePath = pagePath.slice(0, -9) + '.md'
pageHash = __VP_HASH_MAP__[pagePath.toLowerCase()]
}
pagePath = `${base}assets/${pagePath}.${pageHash}.js`
} else {
// ssr build uses much simpler name mapping
Expand Down