Replace strings.Index usages with strings.Cut (#4930)

This commit is contained in:
WilczyńskiT
2022-08-04 19:17:35 +02:00
committed by GitHub
parent 17ae5acaba
commit 2642bd72b7
8 changed files with 32 additions and 33 deletions

View File

@ -610,11 +610,11 @@ func (m *MatchQuery) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
if query == "" {
continue
}
parts := strings.SplitN(query, "=", 2)
if len(parts) != 2 {
before, after, found := strings.Cut(query, "=")
if !found {
return d.Errf("malformed query matcher token: %s; must be in param=val format", d.Val())
}
url.Values(*m).Add(parts[0], parts[1])
url.Values(*m).Add(before, after)
}
if d.NextBlock(0) {
return d.Err("malformed query matcher: blocks are not supported")