From 329a8ebc2baf45ca5827a267fec30f3df9821e84 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Thu, 22 Mar 2018 01:39:02 +0900 Subject: [PATCH] Support all of paths which end with slash --- .../scala/gitbucket/core/controller/ControllerBase.scala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/scala/gitbucket/core/controller/ControllerBase.scala b/src/main/scala/gitbucket/core/controller/ControllerBase.scala index d7bde6129..b4ad4a7fc 100644 --- a/src/main/scala/gitbucket/core/controller/ControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/ControllerBase.scala @@ -43,6 +43,15 @@ abstract class ControllerBase extends ScalatraFilter contentType = formats("json") } + override def requestPath(uri: String, idx: Int): String = { + val path = super.requestPath(uri, idx) + if(path != "/" && path.endsWith("/")){ + path.substring(0, path.length - 1) + } else { + path + } + } + override def doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain): Unit = try { val httpRequest = request.asInstanceOf[HttpServletRequest] val context = request.getServletContext.getContextPath