MCPcopy
hub / github.com/gorilla/websocket / equalASCIIFold

Function equalASCIIFold

util.go:178–198  ·  view source on GitHub ↗

equalASCIIFold returns true if s is equal to t with ASCII case folding as defined in RFC 4790.

(s, t string)

Source from the content-addressed store, hash-verified

176// equalASCIIFold returns true if s is equal to t with ASCII case folding as
177// defined in RFC 4790.
178func equalASCIIFold(s, t string) bool {
179 for s != "" && t != "" {
180 sr, size := utf8.DecodeRuneInString(s)
181 s = s[size:]
182 tr, size := utf8.DecodeRuneInString(t)
183 t = t[size:]
184 if sr == tr {
185 continue
186 }
187 if 'A' <= sr && sr <= 'Z' {
188 sr = sr + 'a' - 'A'
189 }
190 if 'A' <= tr && tr <= 'Z' {
191 tr = tr + 'a' - 'A'
192 }
193 if sr != tr {
194 return false
195 }
196 }
197 return s == t
198}
199
200// tokenListContainsValue returns true if the 1#token header with the given
201// name contains a token equal to value with ASCII case folding.

Callers 3

checkSameOriginFunction · 0.85
TestEqualASCIIFoldFunction · 0.85
tokenListContainsValueFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestEqualASCIIFoldFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…