Skip to content

feat(trail): slash support#26

Open
MadebyAe wants to merge 1 commit intosPavl0v:masterfrom
MadebyAe:feat/trail-slash-support
Open

feat(trail): slash support#26
MadebyAe wants to merge 1 commit intosPavl0v:masterfrom
MadebyAe:feat/trail-slash-support

Conversation

@MadebyAe
Copy link
Copy Markdown

Fix: Generate index.html for routes with trailing slashes

Problem
Routes ending with a trailing slash (e.g. /about/, /work/project/) currently generate invalid paths like dist/about/.html instead of dist/about/index.html, breaking standard web server behavior.

Root Cause
getValidatedFileName.js always appends .html to routes without extensions, ignoring trailing slashes.

Solution
Update logic to detect trailing slashes and append index.html instead of .html:

return fileName.endsWith('/')
  ? `${fileName}index.html`
  : `${fileName}.html`;

Examples

Route Before After
/about/ dist/about/.html dist/about/index.html
/work/project/ dist/work/project/.html dist/work/project/index.html

Backward Compatibility

  • /page/page.html (unchanged)
  • //index.html (unchanged)
  • /page.html/page.html (unchanged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant