Pass parsed URL to isGravatarAvatar instead of URL string which then has to be parsed.

This commit is contained in:
Brent Simmons committed 2026-10-30 18:19:06 -07:00
1 parent 21543b9ee0
commit 88104fb412
2 files changed
+4 -4

No files matched your search

@@ -29,8 +29,8 @@ enum MediaRSS {
private static let gravatarSubdomainSuffix = ".gravatar.com"
private static let gravatarAvatarPathPrefix = "/avatar/"
static func isGravatarAvatar(_ urlString: String) -> Bool {
guard let url = URL(string: urlString), let host = url.host()?.lowercased() else {
static func isGravatarAvatar(_ url: URL) -> Bool {
guard let host = url.host()?.lowercased() else {
return false
}
let isGravatarHost = host == gravatarHost || host.hasSuffix(gravatarSubdomainSuffix)
@@ -83,7 +83,7 @@ struct MediaElementTracker {
group?.add(attachment, isDefault: MediaRSS.isDefault(attributes))
} else {
item.attachments.append(attachment)
if MediaRSS.isGravatarAvatar(url) {
if let parsedURL = URL(string: url), MediaRSS.isGravatarAvatar(parsedURL) {
gravatarURL = url
}
}
@@ -111,7 +111,7 @@ private extension SignificantImageFilter {
if matches(host: host, path: url.path().lowercased(), blockedImagePrefixes) {
return true
}
return MediaRSS.isGravatarAvatar(urlString)
return MediaRSS.isGravatarAvatar(url)
}
/// Includes `mailto:` links, the usual target of an email-this-article button.