Skip to content
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

Support trailing slash behavior customization #588

Open
bitspittle opened this issue Aug 7, 2024 · 5 comments
Open

Support trailing slash behavior customization #588

bitspittle opened this issue Aug 7, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@bitspittle
Copy link
Collaborator

See also: https://nextjs.org/docs/pages/api-reference/next-config-js/trailingSlash

And see also:

Up until now, we've sidestepped this by being pretty loose with trailing slashes in Kobweb.

In other words, if a user registers "/example-route", then that route will be visited (of course) if typed in directly or if /example-route/ was typed in (at which point it would be redirected).

Some users want the reverse -- they want the trailing-slash version to be the canonical URL, so even if they define a @Page (or markdown file) at ExampleRoute.kt, it should generate /example-route/

The one tricky thing with Kobweb is we let users break their code up into separate modules (and libraries), but for consistency, this is probably something we only want to let the app decide on the final behavior, and not have to specify in every module.

So we'd probably need a way to take a route registered at "/a/b/c" and retroactively treat it as "/a/b/c/" (unless of course "/a/b/c/" was separately registered explicilty.

@bitspittle bitspittle added the enhancement New feature or request label Aug 7, 2024
@shubhamsinghshubham777
Copy link

Any updates on this @bitspittle?

@bitspittle
Copy link
Collaborator Author

bitspittle commented Dec 25, 2024

I'll be honest, it hasn't been on my radar and might not be for a while.

Note that you have access to registering a route interceptor:

And also the client side navigation logic will try to add a slash if /example-route isn't found but /example-route/ is:

and a fullstack Kobweb server will handle that case too. (A static hosting service would probably fail though without configuration)

@shubhamsinghshubham777 Can you share a specific use case would you like to support?

@shubhamsinghshubham777
Copy link

the client side navigation logic will try to add a slash if /example-route isn't found but /example-route/ is

@bitspittle My case is similar, but for query parameters. The router is able to find this path:

http://localhost:8080/results/?search_query=test

but not this:

http://localhost:8080/results?search_query=test

Let me know if this should be filed under its own issue.

@bitspittle
Copy link
Collaborator Author

Ah sure, let's file a new issue for that! Because we could fix it without adding a trailing slash config parameter. I will need to double check the code, but that probably should have worked and it's just an oversight with my logic.

@shubhamsinghshubham777
Copy link

Ah sure, let's file a new issue for that! Because we could fix it without adding a trailing slash config parameter. I will need to double check the code, but that probably should have worked and it's just an oversight with my logic.

No issues at all, I'll file another issue to keep things clean ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants