From 27366569f7fe8ac4cf698f1ee29ba6ef1960b9e7 Mon Sep 17 00:00:00 2001 From: David Russell Date: Sun, 30 Apr 2017 22:07:43 +0700 Subject: [PATCH] Auto-redirect superfluous trailing slashes on presentaton URLs. --- app/com/gitpitch/controllers/PitchController.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/com/gitpitch/controllers/PitchController.java b/app/com/gitpitch/controllers/PitchController.java index 1225e76..eb68b1e 100644 --- a/app/com/gitpitch/controllers/PitchController.java +++ b/app/com/gitpitch/controllers/PitchController.java @@ -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("/"); + } } /*