MCPcopy Create free account
hub / github.com/andybalholm/cascadia / attributeSubstringMatch

Function attributeSubstringMatch

selector.go:400–411  ·  view source on GitHub ↗

attributeSubstringMatch matches nodes where the attribute named key contains val.

(key, val string, n *html.Node, ignoreCase bool)

Source from the content-addressed store, hash-verified

398// attributeSubstringMatch matches nodes where
399// the attribute named key contains val.
400func attributeSubstringMatch(key, val string, n *html.Node, ignoreCase bool) bool {
401 return matchAttribute(n, key,
402 func(s string) bool {
403 if strings.TrimSpace(s) == "" {
404 return false
405 }
406 if ignoreCase {
407 return strings.Contains(strings.ToLower(s), strings.ToLower(val))
408 }
409 return strings.Contains(s, val)
410 })
411}
412
413// attributeRegexMatch matches nodes where
414// the attribute named key matches the regular expression rx

Callers 1

MatchMethod · 0.85

Calls 1

matchAttributeFunction · 0.85

Tested by

no test coverage detected