mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-12-24 09:20:04 +01:00
fix path parameter in get-contents API
This commit is contained in:
@@ -109,14 +109,13 @@ trait ApiControllerBase extends ControllerBase {
|
||||
* https://developer.github.com/v3/repos/contents/#get-contents
|
||||
*/
|
||||
get("/api/v3/repos/:owner/:repo/contents/*")(referrersOnly { repository =>
|
||||
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||
val path = multiParams("splat").head match {
|
||||
case s if s.isEmpty => "."
|
||||
case s => s
|
||||
}
|
||||
val refStr = params.getOrElse("ref", repository.repository.defaultBranch)
|
||||
using(Git.open(getRepositoryDir(params("owner"), params("repo")))){ git =>
|
||||
if (path.isEmpty) {
|
||||
JsonFormat(getFileList(git, refStr, ".").map{f => ApiContents(f)})
|
||||
} else {
|
||||
JsonFormat(getFileList(git, refStr, path).map{f => ApiContents(f)})
|
||||
}
|
||||
JsonFormat(getFileList(git, refStr, path).map{f => ApiContents(f)})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user