Merge pull request #1921 from gitbucket/path-end-slash

Support all of paths which end with slash
This commit is contained in:
Naoki Takezoe
2018-03-27 00:55:08 +09:00
committed by GitHub
3 changed files with 11 additions and 2 deletions

View File

@@ -77,7 +77,7 @@ trait ApiControllerBase extends ControllerBase {
/**
* https://developer.github.com/v3/#root-endpoint
*/
get("/api/v3/") {
get("/api/v3") {
JsonFormat(ApiEndPoint())
}

View File

@@ -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

View File

@@ -109,7 +109,7 @@ trait WikiControllerBase extends ControllerBase {
val Array(from, to) = params("commitId").split("\\.\\.\\.")
if(revertWikiPage(repository.owner, repository.name, from, to, context.loginAccount.get, None)){
redirect(s"/${repository.owner}/${repository.name}/wiki/")
redirect(s"/${repository.owner}/${repository.name}/wiki")
} else {
flash += "info" -> "This patch was not able to be reversed."
redirect(s"/${repository.owner}/${repository.name}/wiki/_compare/${from}...${to}")