mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-11 10:05:27 +00:00
Fixed an Unhandled Error in badges.go
There was an unhandled error in badges.go. If you pass an invalid branch to the badge handler (http://beta.drone.io/github.com/drone/drone/ status.svg?branch=this) the browser is told to redirect to a blank string. This is unintended behavior. Now, a 404 response is sent instead.
This commit is contained in:
parent
0d25dc1595
commit
c6930ef57b
1 changed files with 23 additions and 20 deletions
|
@ -43,7 +43,11 @@ func Badge(w http.ResponseWriter, r *http.Request) error {
|
||||||
// get the latest commit from the database
|
// get the latest commit from the database
|
||||||
// for the requested branch
|
// for the requested branch
|
||||||
commit, err := database.GetBranch(repo.ID, branchParam)
|
commit, err := database.GetBranch(repo.ID, branchParam)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case commit.Status == "Success" && len(successParam) == 0:
|
case commit.Status == "Success" && len(successParam) == 0:
|
||||||
// if no success image is provided, we serve a
|
// if no success image is provided, we serve a
|
||||||
|
@ -63,7 +67,6 @@ func Badge(w http.ResponseWriter, r *http.Request) error {
|
||||||
// otherwise load unknown image
|
// otherwise load unknown image
|
||||||
badge = badgeUnknown
|
badge = badgeUnknown
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, badge, http.StatusSeeOther)
|
http.Redirect(w, r, badge, http.StatusSeeOther)
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue