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
Prev Previous commit
Next Next commit
fix: fallback to previous behaviour in DEV mode
  • Loading branch information
rigor789 committed Dec 21, 2022
commit affdecaf46b08bed54e607db681b644e26ecdcfa
10 changes: 8 additions & 2 deletions src/client/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export function pathToFile(path: string): string {
pagePath = decodeURIComponent(pagePath)

if (pagePath.endsWith('/')) {
// remove trailing slashes from pagePath
pagePath = pagePath.slice(0, -1)
if (import.meta.env.DEV) {
// in dev, we are importing the md files directly, and if there's a trailing slash
// it's likely an index.md file
pagePath += 'index'
} else {
// remove trailing slashes from pagePath
pagePath = pagePath.slice(0, -1)
}
}

// if we removed the trailing slash and have an empty page path
Expand Down