1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Inline a function and fix a bug in it

The `isAnchor` function's first parameter was always `a`, instead of being
passed `tagName`. As this function is a single line and was only called in a
single place, it can be inlined.
This commit is contained in:
jvoisin 2024-12-07 23:00:42 +01:00 committed by Frédéric Guillot
parent 2314500515
commit 902ca63c45

View file

@ -195,7 +195,7 @@ func sanitizeAttributes(baseURL, tagName string, attributes []html.Attribute) ([
value = rewriteIframeURL(attribute.Val) value = rewriteIframeURL(attribute.Val)
case tagName == "img" && attribute.Key == "src" && isValidDataAttribute(attribute.Val): case tagName == "img" && attribute.Key == "src" && isValidDataAttribute(attribute.Val):
value = attribute.Val value = attribute.Val
case isAnchor("a", attribute): case tagName == "a" && attribute.Key == "href" && strings.HasPrefix(attribute.Val, "#"):
value = attribute.Val value = attribute.Val
isAnchorLink = true isAnchorLink = true
default: default:
@ -443,10 +443,6 @@ func isValidDataAttribute(value string) bool {
}) })
} }
func isAnchor(tagName string, attribute html.Attribute) bool {
return tagName == "a" && attribute.Key == "href" && strings.HasPrefix(attribute.Val, "#")
}
func isPositiveInteger(value string) bool { func isPositiveInteger(value string) bool {
if number, err := strconv.Atoi(value); err == nil { if number, err := strconv.Atoi(value); err == nil {
return number > 0 return number > 0