- `internal/updater/html` package - Add unit tests for slickvpn updating code - Change shared html package to be more share-able - Split html utilities in multiple files - Fix processing .ovpn files with prefix space Authored by @Rohaq Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
23 lines
482 B
Go
23 lines
482 B
Go
package html
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"golang.org/x/net/html"
|
|
)
|
|
|
|
func HasClassStrings(node *html.Node, classStrings ...string) (match bool) {
|
|
targetClasses := make(map[string]struct{}, len(classStrings))
|
|
for _, classString := range classStrings {
|
|
targetClasses[classString] = struct{}{}
|
|
}
|
|
|
|
classAttribute := Attribute(node, "class")
|
|
classes := strings.Fields(classAttribute)
|
|
for _, class := range classes {
|
|
delete(targetClasses, class)
|
|
}
|
|
|
|
return len(targetClasses) == 0
|
|
}
|