Spark: Routes should match with and without trailing slash

Created on 31 Aug 2013  路  6Comments  路  Source: perwendel/spark

It would be nice if "/route" match "/route" and also "/route/"
Not a big issue. but some browsers put the trailing slash automatically, so sometimes it's annoying.

Feature request

Most helpful comment

Perhaps there could be a built-in configuration option for Spark that would allow for both routes to be created with the same handler (that defaults to off)?

All 6 comments

Any particular reason why this feature wasn't accepted?

I would also like to know why this wasn't accepted. I would very much like this feature.

A trailing slash is often added to request URLs and, as far as I know, it is still the same meaning for RESTful operations.

Ditto for me. This would remove a lot of duplicated routes

Technically they are all different routes /route and /route/ are different from each other. So Spark is preforming the correct action that needs to be done.

Perhaps there could be a built-in configuration option for Spark that would allow for both routes to be created with the same handler (that defaults to off)?

The URI spec says they are different only if they are actually different, and if they are the same then one should redirect to the other. Remember that this mostly comes from Unix file systems where no-slash means file and a slash means folder. In terms of most websites and the expectations of most end users the expectation is that they are the same. I would suggest there be a option to force redirects to / automatically and that this option is on by default.

https://tools.ietf.org/html/rfc3986#section-6.2.4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wowselim picture wowselim  路  5Comments

kiriti999 picture kiriti999  路  4Comments

xizhang picture xizhang  路  6Comments

rbordon-meli picture rbordon-meli  路  5Comments

chibongho picture chibongho  路  4Comments