Auto-redirect superfluous trailing slashes on presentaton URLs.

This commit is contained in:
David Russell 2017-04-30 22:07:43 +07:00
parent 1a894737b3
commit 27366569f7

View File

@ -109,11 +109,20 @@ public class PitchController extends Controller {
}
/*
* Catchall redirects any unhandled URLs to the GitPitch website.
* Catchall redirects any URL with a trailing slash to the
* URL minus the trailing slash. Any remaining unhandled URLs
* are redirected to the GitPitch website.
*/
public Result catchall(String path) {
log.warn("catchall: redirecting from {}", path);
return redirect("/");
try {
if (path != "/" && path.endsWith("/")) {
return redirect("/" + path.substring(0, path.length()-1));
} else {
return redirect("/");
}
} catch(Exception ex) {
return redirect("/");
}
}
/*