From 6002d7260329e4fa22c1069434d58dcc258b15c8 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 20 Feb 2017 18:05:34 -0500 Subject: router: fix 404 when repository name contains dot E.g. atomi.github.io --- cmd/web.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/web.go b/cmd/web.go index 92fbe2a7..7f00e239 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -632,14 +632,17 @@ func runWeb(ctx *cli.Context) error { }, ignSignIn, context.RepoAssignment(), context.RepoRef()) m.Group("/:username", func() { - m.Group("/:reponame", func() { - m.Get("", repo.Home) - m.Get("\\.git$", repo.Home) + m.Group("", func() { + m.Get("/:reponame", repo.Home) }, ignSignIn, context.RepoAssignment(true), context.RepoRef()) m.Group("/:reponame", func() { m.Head("/tasks/trigger", repo.TriggerTask) - m.Route("\\.git/*", "GET,POST", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP) + }) + // Use the regexp to match the repository name validation + m.Group("/:reponame([\\d\\w-_\\.]+\\.git$)", func() { + m.Get("", ignSignIn, context.RepoAssignment(true), context.RepoRef(), repo.Home) + m.Route("/*", "GET,POST", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP) }) }) // ***** END: Repository ***** -- cgit v1.2.3