From d8f89726fec3822d7d1dd42c52f478f37003b534 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Thu, 2 Aug 2018 23:37:49 +0200 Subject: implement media hosting in git for comments + API for the webui --- commands/webui.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'commands/webui.go') diff --git a/commands/webui.go b/commands/webui.go index d5560180..0389d68b 100644 --- a/commands/webui.go +++ b/commands/webui.go @@ -64,9 +64,9 @@ func newGitFileHandler(repo repository.Repo) http.Handler { } func (gfh *gitFileHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - hash := mux.Vars(r)["hash"] + hash := util.Hash(mux.Vars(r)["hash"]) - if !isGitHash(hash) { + if !hash.IsValid() { http.Error(rw, "invalid git hash", http.StatusBadRequest) return } @@ -144,18 +144,6 @@ func (gufh *gitUploadFileHandler) ServeHTTP(rw http.ResponseWriter, r *http.Requ rw.Write(js) } -func isGitHash(s string) bool { - if len(s) != 40 { - return false - } - for _, r := range s { - if (r < 'a' || r > 'z') && (r < '0' || r > '9') { - return false - } - } - return true -} - var webUICmd = &cobra.Command{ Use: "webui", Short: "Launch the web UI", -- cgit