feat: SlickVPN Support (#961)
- `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>
This commit is contained in:
22
internal/updater/html/css.go
Normal file
22
internal/updater/html/css.go
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user