Skip to content

Commit

Permalink
Fix magnet url parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
WinPooh32 committed Jan 28, 2023
1 parent 7cff9f0 commit 70269fa
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions http/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,9 @@ func hash(next http.Handler) http.Handler {

func magnet(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var parts = strings.Split(r.URL.RawQuery, "&")
var magnetURI = chi.URLParam(r, "*") + "?" + r.URL.RawQuery

if len(parts) == 0 {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}

parts[0] = strings.ToLower(parts[0])

var magnetURI = chi.URLParam(r, "*") + "?" + strings.Join(parts, "&")
var magnet, err = metainfo.ParseMagnetUri(magnetURI)

if err != nil {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
Expand Down

0 comments on commit 70269fa

Please sign in to comment.