Merge pull request #1873 from kounoike/fix-1872
fix 1872.
commit 95acb8593aa7575f34842c1a83bb3a9e96946074
2 parents 952c916 + 17d682f
@Naoki Takezoe Naoki Takezoe authored on 3 Feb 2018
GitHub committed on 3 Feb 2018
Showing 1 changed file
View
14
src/main/scala/gitbucket/core/controller/ApiController.scala
* https://developer.github.com/v3/repos/contents/#get-contents
*/
get("/api/v3/repos/:owner/:repo/contents/*")(referrersOnly { repository =>
def getFileInfo(git: Git, revision: String, pathStr: String): Option[FileInfo] = {
val path = new java.io.File(pathStr)
val dirName = path.getParent match {
case null => "."
case s => s
}
getFileList(git, revision, dirName).find(f => f.name.equals(path.getName))
val (dirName, fileName) = pathStr.lastIndexOf('/') match {
case -1 =>
(".", pathStr)
case n =>
(pathStr.take(n), pathStr.drop(n + 1))
}
getFileList(git, revision, dirName).find(f => f.name.equals(fileName))
}
 
val path = multiParams("splat").head match {
case s if s.isEmpty => "."