cmd: modernize -fix ./cmd/...

This commit is contained in:
nkanaev
2026-04-27 20:44:24 +01:00
parent 7a5f8a5e41
commit 49c704037b
15 changed files with 53 additions and 75 deletions

View File

@@ -9,6 +9,7 @@ import (
"fmt"
"io"
"regexp"
"slices"
"strconv"
"strings"
@@ -225,10 +226,8 @@ func hasRequiredAttributes(tagName string, attributes []string) bool {
for element, attrs := range elements {
if tagName == element {
for _, attribute := range attributes {
for _, attr := range attrs {
if attr == attribute {
return true
}
if slices.Contains(attrs, attribute) {
return true
}
}
@@ -285,13 +284,7 @@ func isValidIframeSource(baseURL, src string) bool {
return true
}
for _, safeDomain := range whitelist {
if safeDomain == domain {
return true
}
}
return false
return slices.Contains(whitelist, domain)
}
func getTagAllowList() map[string][]string {
@@ -355,13 +348,7 @@ func getTagAllowList() map[string][]string {
}
func inList(needle string, haystack []string) bool {
for _, element := range haystack {
if element == needle {
return true
}
}
return false
return slices.Contains(haystack, needle)
}
func isBlockedTag(tagName string) bool {
@@ -371,13 +358,7 @@ func isBlockedTag(tagName string) bool {
"style",
}
for _, element := range blacklist {
if element == tagName {
return true
}
}
return false
return slices.Contains(blacklist, tagName)
}
/*

View File

@@ -2,6 +2,7 @@ package scraper
import (
"net/url"
"slices"
"strings"
"github.com/nkanaev/yarr/src/content/htmlutil"
@@ -22,10 +23,8 @@ func FindFeeds(body string, base string) map[string]string {
isFeedLink := func(n *html.Node) bool {
if n.Type == html.ElementNode && n.Data == "link" {
t := htmlutil.Attr(n, "type")
for _, tt := range linkTypes {
if tt == t {
return true
}
if slices.Contains(linkTypes, t) {
return true
}
}
return false