diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index 61642c7..a99973b 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -822,12 +822,43 @@ }) /** - * Download repository contents as an archive as compatible URL. + * Download repository contents as a zip archive as compatible URL. */ - get("/:owner/:repository/archive/:branch.:suffix")(referrersOnly { repository => + get("/:owner/:repository/archive/:branch.zip")(referrersOnly { repository => val branch = params("branch") - val suffix = params("suffix") - archiveRepository(branch, branch + "." + suffix, repository, "") + archiveRepository(branch, branch + ".zip", repository, "") + }) + + /** + * Download repository contents as a tar.gz archive as compatible URL. + */ + get("/:owner/:repository/archive/:branch.tar.gz")(referrersOnly { repository => + val branch = params("branch") + archiveRepository(branch, branch + ".tar.gz", repository, "") + }) + + /** + * Download repository contents as a tar.gz archive as compatible URL. + */ + get("/:owner/:repository/archive/:branch.tar.gz")(referrersOnly { repository => + val branch = params("branch") + archiveRepository(branch, branch + ".tar.gz", repository, "") + }) + + /** + * Download repository contents as a tar.bz2 archive as compatible URL. + */ + get("/:owner/:repository/archive/:branch.tar.bz2")(referrersOnly { repository => + val branch = params("branch") + archiveRepository(branch, branch + ".tar.bz2", repository, "") + }) + + /** + * Download repository contents as a tar.xz archive as compatible URL. + */ + get("/:owner/:repository/archive/:branch.tar.xz")(referrersOnly { repository => + val branch = params("branch") + archiveRepository(branch, branch + ".tar.bz2", repository, "") }) /** @@ -1134,7 +1165,7 @@ } } - def archiveRepository( + private def archiveRepository( revision: String, filename: String, repository: RepositoryService.RepositoryInfo, @@ -1176,7 +1207,8 @@ } } - val suffix = path.split("/").lastOption.map("-" + _).getOrElse("") + val suffix = + path.split("/").lastOption.collect { case x if x.length > 0 => "-" + x.replace('/', '_') }.getOrElse("") val zipRe = """(.+)\.zip$""".r val tarRe = """(.+)\.tar\.(gz|bz2|xz)$""".r