Skip to content

Commit

Permalink
fix: handle cleanUrls with subfolders when using a trailing slash (#1575
Browse files Browse the repository at this point in the history
)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
  • Loading branch information
rigor789 and brc-dd committed Dec 22, 2022
1 parent bf1315a commit 195d867
Showing 1 changed file with 6 additions and 5 deletions.
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

0 comments on commit 195d867

Please sign in to comment.