route-parser icon indicating copy to clipboard operation
route-parser copied to clipboard

slash at the end of route

Open omerts opened this issue 8 years ago • 5 comments

Hey,

Currently when there is a slash at the end of a route, the match function returns false. For example:

routeParser('/test').match('/test/') // false

Is this the expected behavior? Shouldn't the above return a truthful value, since the slash at the end doesn't have a real meaning?

omerts avatar Jan 12 '17 11:01 omerts

They are technically two different routes, and I believe google would index them as such? I could be wrong though.

firasdib avatar Feb 07 '17 09:02 firasdib

@firasdib From what I know, websites will serve the same content if there is or isn't a preceding slash. Just try to add/remove the trailing slash from this issue :).

omerts avatar Feb 07 '17 20:02 omerts

@omerts Read this https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html

firasdib avatar Feb 07 '17 20:02 firasdib

@firasdib while you are technically right it does seem other routers might treat it (wrongly?) as if it was the same route. I guess a note in the documentation would prevent some surprises.

goliatone avatar Mar 05 '18 20:03 goliatone

@goliatone Can confirm a note in the documentation would have prevented me some surprises :)

pietrovismara avatar Oct 19 '22 11:10 pietrovismara