Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
trailingSlash feature parity between now and serve #3731
I'm not sure if this i a legit issue, but I can see that
The Serve README also says:
Anyhow, there is an inconsistency when using the
I've setup a reproducible test-case here: https://github.com/danielstocks/trailing-slash-experiments.
So my question is: Is this by design or can it be considered a bug?
Thanks in advance
The expected behavior when
There is no difference for directories or files.
I will discuss with the team if we can detect directories in production to make the behavior more nuanced but we will probably choose to keep it as-is to avoid the performance hit.
@styfle Thanks for the clarification!
And yes, to be fair
I think from a developer experience standpoint I was just confused as
By looking at commits logs I've gathered that the
Given the amount of stuff that is already going on in the route-handler I have a hard time imagining that using a regex to check for a file extension will have have any substantial performance regressions? After all:
Edit: updated test case to include superstatic, which has the same behaviour as serve: https://github.com/danielstocks/trailing-slash-experiments.
To circle back to why I want to redirect in the first place, here is the same page deployed with the
As you can see, it's the same page, but it loads different CSS files depending if it has a trailing slash or not. In addition: Google et al. will treat it as as two separate pages with duplicate content.
#3745) This PR changes the behavior of `trailingSlash: true` after we received feedback that files should not be redirected with a trailing slash. This matches the behavior of `serve` and `serve-handler`. ### Examples * `/index.html` => serve * `/assets/style.css` => serve * `/assets` => redirect to `/assets/` * `/assets/style` => redirect to `/assets/style/` ### Additional In order to avoid duplicate content, this PR also adds redirects to files without a trailing slash. * `/about.html/` => redirect to `/about.html` * `/assets/style.css/` => redirect to `/assets/style.css` Fixes #3731