perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

Fix issue 1056 handling the trailing slash #1219

Open Lloyd-Pottiger opened 3 years ago

Lloyd-Pottiger commented 3 years ago

http://sparkjava.com/documentation#redirects, method doesn't seem to work when I try to add the trailing slash. And it does not match trailing slashes with a mapped route. So it considers /api/test and /api/test/ as different URIs. This commit solve thoese problem with little change in code. The changed file: src/main/java/spark/http/matching/MatcherFilter.java line 107, add

108 if (uri.length() > 1 && uri.endsWith("/"))
109           uri = uri.substring(0, uri.length() - 1);