diff options
author | Michael Muré <batolettre@gmail.com> | 2018-08-02 23:37:49 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-08-02 23:37:49 +0200 |
commit | d8f89726fec3822d7d1dd42c52f478f37003b534 (patch) | |
tree | 567e97ee605ef3a286e42e11535fa6516321e743 /commands | |
parent | ed8f7eca9a8e0d1c448a7cc6240e2b7e357cf354 (diff) | |
download | git-bug-d8f89726fec3822d7d1dd42c52f478f37003b534.tar.gz |
implement media hosting in git for comments + API for the webui
Diffstat (limited to 'commands')
-rw-r--r-- | commands/webui.go | 16 |
1 files changed, 2 insertions, 14 deletions
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", |