react-router-component icon indicating copy to clipboard operation
react-router-component copied to clipboard

Ability to support trailing slash as a parameter to the Locations component

Open meghprkh opened this issue 9 years ago • 3 comments

IMHO the locations component should have a boolean flag trailingSlash which when set allows all its children to have trailing slashes without having to explicitly specify (/) at the end of the path

meghprkh avatar Jun 16 '16 20:06 meghprkh

If you think that would be useful to you, please create a PR and I will review it.

STRML avatar Jun 16 '16 20:06 STRML

Sure. Will do it in my spare time, currently keen on completing my project. Leaving this issue open as of now.

meghprkh avatar Jun 16 '16 20:06 meghprkh

Note also that it's a bad habit to have two URLs refer to the same resource without a redirect. There was a similar issue in url-pattern, which this library uses.

You could set an onBeforeNavigation handler that checks if the current route has a trailing slash, and if it does, calls this.setPath() again with the trailing slash removed, and returns false so the original navigation is canceled.

STRML avatar Jul 12 '16 21:07 STRML