pluginpal/strapi-webtools

Feature: Option to ignore trailing slash or automatically append trailing slash

Opened this issue · 2 comments

Feature request

Summary

I mostly use urls without trailing slashes, but some of the users of our strapi deployments may mistakenly set a trailing slash when creating a custom url alias. For example /about/, this mean I cannot fetch the entry by using /webtools/router?path=/about. From a user perspective /about and /about/ will be the same, this it would be nice to have an option such that they would resolve to the same and you could not have a page with both paths.

Why is it needed?

Some users are not the most technical and I also believe it is needed for "idiot proofing"

Suggested solution(s)

  1. No duplicates: whenever a path is updated or created, we should check whether or not the path exists with or without trailing slash.
  2. Enforce style: Whether or not the plugin should enforce using trailing slashes or no trailing slashes. This would mean that it should check the url path before saving and either remove or set trailing slashes.

I like suggested solution 2.
Definetly if this is something that can be controlled through plugin options by the end user.

For my use case I am using nextjs and nextjs seems to redirect you if you are using trailing slashes, which means the router never has a trailing slash. Because of this I would like it to be something that only the developer can change. (nextjs docs)

On the other hand, other frontends might just not care about this and then it would make sense that the end user could change this option.

So maybe this could be an option in the plugin configuration in config/plugins.ts?