summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/push
diff options
context:
space:
mode:
authorWilczyƄskiT <102859171+WilczynskiT@users.noreply.github.com>2022-08-04 19:17:35 +0200
committerGitHub <noreply@github.com>2022-08-04 11:17:35 -0600
commit2642bd72b7ca35b8622824fdffced2aefe1aaf11 (patch)
tree3bc73bada610bfee6377eb58d89ca18b72236966 /modules/caddyhttp/push
parent17ae5acaba536e98cfa86ddcd6967801f1fa1bbe (diff)
Replace strings.Index usages with strings.Cut (#4930)
Diffstat (limited to 'modules/caddyhttp/push')
-rw-r--r--modules/caddyhttp/push/link.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/modules/caddyhttp/push/link.go b/modules/caddyhttp/push/link.go
index 16b0e7d..f7c1dd8 100644
--- a/modules/caddyhttp/push/link.go
+++ b/modules/caddyhttp/push/link.go
@@ -52,17 +52,16 @@ func parseLinkHeader(header string) []linkResource {
l.uri = strings.TrimSpace(link[li+1 : ri])
for _, param := range strings.Split(strings.TrimSpace(link[ri+1:]), semicolon) {
- parts := strings.SplitN(strings.TrimSpace(param), equal, 2)
- key := strings.TrimSpace(parts[0])
+ before, after, isCut := strings.Cut(strings.TrimSpace(param), equal)
+ key := strings.TrimSpace(before)
if key == "" {
continue
}
- if len(parts) == 1 {
+ if isCut {
+ l.params[key] = strings.TrimSpace(after)
+ } else {
l.params[key] = key
}
- if len(parts) == 2 {
- l.params[key] = strings.TrimSpace(parts[1])
- }
}
resources = append(resources, l)