Skip to content

Commit

Permalink
Make Subsonic search query default to "" if not present.
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Jan 28, 2024
1 parent 5f9b6b6 commit 5125558
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions server/subsonic/searching.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ type searchParams struct {
songOffset int
}

func (api *Router) getParams(r *http.Request) (*searchParams, error) {
func (api *Router) getSearchParams(r *http.Request) (*searchParams, error) {
p := req.Params(r)
var err error
sp := &searchParams{}
sp.query, err = p.String("query")
if err != nil {
return nil, err
}
sp.query = p.StringOr("query", `""`)
sp.artistCount = p.IntOr("artistCount", 20)
sp.artistOffset = p.IntOr("artistOffset", 0)
sp.albumCount = p.IntOr("albumCount", 20)
Expand Down Expand Up @@ -91,7 +87,7 @@ func (api *Router) searchAll(ctx context.Context, sp *searchParams) (mediaFiles

func (api *Router) Search2(r *http.Request) (*responses.Subsonic, error) {
ctx := r.Context()
sp, err := api.getParams(r)
sp, err := api.getSearchParams(r)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -122,7 +118,7 @@ func (api *Router) Search2(r *http.Request) (*responses.Subsonic, error) {

func (api *Router) Search3(r *http.Request) (*responses.Subsonic, error) {
ctx := r.Context()
sp, err := api.getParams(r)
sp, err := api.getSearchParams(r)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 5125558

Please sign in to comment.