MCPcopy
hub / github.com/gofiber/fiber / acceptsLanguageOfferBasic

Function acceptsLanguageOfferBasic

helpers.go:263–276  ·  view source on GitHub ↗

acceptsLanguageOfferBasic determines if a language tag offer matches a range according to RFC 4647 Basic Filtering. A match occurs if the range exactly equals the tag or is a prefix of the tag followed by a hyphen. The comparison is case-insensitive. Only a single "*" as the entire range is allowed.

(spec, offer string, _ headerParams)

Source from the content-addressed store, hash-verified

261// as the entire range is allowed. Any "*" appearing after a hyphen renders the
262// range invalid and will not match.
263func acceptsLanguageOfferBasic(spec, offer string, _ headerParams) bool {
264 if spec == "*" {
265 return true
266 }
267 if strings.IndexByte(spec, '*') >= 0 {
268 return false
269 }
270 if utils.EqualFold(spec, offer) {
271 return true
272 }
273 return len(offer) > len(spec) &&
274 utils.EqualFold(offer[:len(spec)], spec) &&
275 offer[len(spec)] == '-'
276}
277
278// acceptsLanguageOfferExtended determines if a language tag offer matches a
279// range according to RFC 4647 Extended Filtering (§3.3.2).

Callers 1

Test_Utils_GetOfferFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_Utils_GetOfferFunction · 0.68