-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Description
Hi! This is a weird one.
gatsby develop uses parse-filepath to grab the extension from a URL and serve public/index.html:
gatsby/packages/gatsby/src/commands/develop.js
Lines 146 to 158 in b21a022
| // Render an HTML page and serve it. | |
| app.use((req, res, next) => { | |
| const parsedPath = parsePath(req.path) | |
| if (parsedPath.extname === `` || parsedPath.extname.startsWith(`.html`)) { | |
| res.sendFile(directoryPath(`public/index.html`), err => { | |
| if (err) { | |
| res.status(500).end() | |
| } | |
| }) | |
| } else { | |
| next() | |
| } | |
| }) |
Line 149 incorrectly fails for our URLs that include a SemVer range at the end.
This happens because parse-filepath believes that a URL like /tp-ui-react-button/1.6.3/ has a file extension of .3:
This causes the development server to throw a 404 when attempting to reload the page: "Cannot GET /tp-ui-react-button/1.6.3/". The reloads work when I use URLs that end in index.html
I'll likely work around this by wrapping gatsby-link to append index.html to URLs on development.
Any thoughts on adding parsedPath.path.endsWith('/') to the conditional on L149? I can make the change if y'all would like.
