Use `strings.EqualFold` instead of `strings.ToLower(…) ==`

This commit is contained in:
jvoisin 2024-02-29 00:28:54 +01:00 committed by Frédéric Guillot
parent 61af08a721
commit 4fe902a5d2
3 changed files with 6 additions and 6 deletions

View File

@ -184,7 +184,7 @@ func (a *atom10Entry) entryEnclosures() model.EnclosureList {
}
for _, link := range a.Links {
if strings.ToLower(link.Rel) == "enclosure" {
if strings.EqualFold(link.Rel, "enclosure") {
if link.URL == "" {
continue
}

View File

@ -46,7 +46,7 @@ type atomLinks []*atomLink
func (a atomLinks) originalLink() string {
for _, link := range a {
if strings.ToLower(link.Rel) == "alternate" {
if strings.EqualFold(link.Rel, "alternate") {
return strings.TrimSpace(link.URL)
}
@ -60,7 +60,7 @@ func (a atomLinks) originalLink() string {
func (a atomLinks) firstLinkWithRelation(relation string) string {
for _, link := range a {
if strings.ToLower(link.Rel) == relation {
if strings.EqualFold(link.Rel, relation) {
return strings.TrimSpace(link.URL)
}
}
@ -70,9 +70,9 @@ func (a atomLinks) firstLinkWithRelation(relation string) string {
func (a atomLinks) firstLinkWithRelationAndType(relation string, contentTypes ...string) string {
for _, link := range a {
if strings.ToLower(link.Rel) == relation {
if strings.EqualFold(link.Rel, relation) {
for _, contentType := range contentTypes {
if strings.ToLower(link.Type) == contentType {
if strings.EqualFold(link.Type, contentType) {
return strings.TrimSpace(link.URL)
}
}

View File

@ -67,7 +67,7 @@ func IsHTTPS(websiteURL string) bool {
return false
}
return strings.ToLower(parsedURL.Scheme) == "https"
return strings.EqualFold(parsedURL.Scheme, "https")
}
// Domain returns only the domain part of the given URL.