Skip to content

Commit

Permalink
fix: allow whole repository url on form
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Aug 5, 2021
1 parent 1f21ac4 commit 862be19
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion controller/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"io/fs"
"net/http"
"strings"

"github.com/caarlos0/httperr"
)
Expand All @@ -17,7 +18,8 @@ func Index(fsys fs.FS, version string) http.Handler {

func HandleForm(fsys fs.FS) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/"+r.FormValue("repository"), http.StatusSeeOther)
repo := strings.TrimPrefix(r.FormValue("repository"), "https://github.com/")
http.Redirect(w, r, repo, http.StatusSeeOther)
}
}

Expand Down

0 comments on commit 862be19

Please sign in to comment.