-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Additional option(s) for trailingSlash
#1405
Comments
Are |
Of these two semantics:
I'd say "How about both?" I can see reasons why either one would be preferred for one person's use case vs. someone else's use case. The name |
Ping @bdadam since he may want to express an opinion on the |
Would it be viable to allow this to be overridden on a per-route basis, like i.e. <script context="module">
export const trailingSlash = 'always';
</script> ...and my routing table would then look something like
where |
#2390 is a use case where a per-route override would make sense. There, the user wants to be able to set |
Per-route is a little tricky, since waiting until the code has loaded to see if there's an override is terrible for performance. We could maybe add new options like Noting that I said 'load the page' rather than 'load the route', since #4699 would mean that |
closing in favour of #7719 |
Is your feature request related to a problem? Please describe.
The
trailingSlash
options introduced in #1404 don't make it straightforward to add trailing slashes to index pages but not to leaf pages. For example you might want to have/blog/
and/blog/some-post
rather than/blog
and/blog-some-post
, since that allows the index page to contain relative links.Describe the solution you'd like
One possibility is to add a
"smart"
option with the semantics described in either #733 (comment) or #733 (comment):index.svelte
file gets a trailing slash if there are also non-index pages in the directory, or in child directoriesindex.svelte
files get a trailing slash (which dictates code organisation decisions, but is probably the decision we'd regret less)There is one problem, described in #733 (comment):
For that reason the
smart
option would have failure cases — rare, and presumably identifiable-at-build-time failure cases, but failure cases nonetheless.So another option is
"strict"
, which would have the semantics describe above but wouldn't cause redirects: a request for/blog
would 404 if the correct path was/blog/
. We could implement one, both or neither.Describe alternatives you've considered
The
"ignore"
setting provides an escape hatch for userland (or upstream, e.g. at the reverse proxy level) solutions, which gives us the option of not worrying about solving this problem. We could also just declare it to not be a problem, and settle for"never"
and"always"
being the only options that will cause an intervention by SvelteKit (as Next does, for example).Per-page settings are also a possibility, though this has major drawbacks as described above.
How important is this feature to you?
Personally I'm good with
"never"
and"always"
, but I can definitely see the argument for/blog/
. I'd rate it as a nice-to-have.The text was updated successfully, but these errors were encountered: