Skip to content

Commit a83c8cc

Browse files
authored
update normalizeEtag
1 parent 66e216f commit a83c8cc

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

helpers.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,17 @@ func sortAcceptedTypes(at []acceptedType) {
493493

494494
// normalizeEtag validates an entity tag and returns the value without quotes.
495495
// weak is true if the tag has the "W/" prefix.
496-
func normalizeEtag(t string) (string, weak, ok bool) {
497-
weak = strings.HasPrefix(t, "W/")
496+
func normalizeEtag(t string) (string, bool, bool) {
497+
weak := strings.HasPrefix(t, "W/")
498498
if weak {
499499
t = t[2:]
500500
}
501501
if len(t) < 2 || t[0] != '"' || t[len(t)-1] != '"' {
502502
return "", weak, false
503503
}
504-
return t[1 : len(t)-1], weak, true
504+
// strip the two surrounding quotes
505+
inner := t[1 : len(t)-1]
506+
return inner, weak, true
505507
}
506508

507509
// matchEtag performs a weak comparison of entity tags according to

0 commit comments

Comments
 (0)