-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 utils/develop path extension check to support location.search #1844
Fix utils/develop path extension check to support location.search #1844
Conversation
Note that client-side routing won't work correctly until the following Gatsby PR has landed: gatsbyjs/gatsby#1844
Deploy preview ready! Built with commit 3455ff9 |
packages/gatsby/src/utils/develop.js
Outdated
@@ -108,7 +108,7 @@ async function startServer(program) { | |||
// Render an HTML page and serve it. | |||
app.use((req, res, next) => { | |||
const parsedPath = parsePath(req.originalUrl) | |||
if (parsedPath.extname === `` || parsedPath.extname === `.html`) { | |||
if (parsedPath.extname === `` || parsedPath.extname.indexOf(`.html`) === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extname.startsWith()
? might be a bit clearer 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay 😛 I guess both are used in this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we are slowly trying reach some sort level consistency on that stuff. Thanks for the change, i realize it's small and a bit inane to have asked 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, it's a great goal. Thanks for pointing it out! 😄
Deploy preview ready! Built with commit 3455ff9 |
So an alternative way to handle this I've been thinking is to just delete all html files from public when starting bootstrap. The reason this check is here is because without it, you'd load html from previous static builds and wonder why changes weren't hot reloading. If we just deleted all html then we could safely load any path in public as all html requests would be handled by webpack-dev-server. |
That sounds reasonable. It seems we could still merge this now and just remove it later if/when you decide to do that though? It would fix a current bug / pain point and it wouldn't (I don't think) cause any regression or negative side effect. |
See the following blockers for the modules I didn't update: * gatsbyjs/gatsby#1844 * gatsbyjs/gatsby#1754
Ah nvm, deleting all html files solves a different problem :-) Merging! Thanks for the PR! |
aww yasssss 🕺 |
This PR adds the ability to define a client-side route that properly supports a dynamic querystring (
location.search
) in development mode.For example
More context available in this discussion thread.
I have not yet tested the production build of the Gatsby site I'm working on but I assume this will work there as-is. (If not I'll follow up with another PR.)