Check for non-empty image URL when handling RSS channel images

This commit is contained in:
Lucidiot 2021-06-14 16:10:11 +02:00
parent 2c1ed1f38b
commit b2cc687059
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
3 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@ def parse_date: ensure_string | strptime("%a, %d %b %Y %T %Z") | mktime | todate
| if $channel.lastBuildDate // $channel.pubDate then .["@LASTMOD"] = (
$channel.lastBuildDate // $channel.pubDate | parse_date
) else . end
| if $channel.image then .LOGO = {
| if $channel.image and $channel.image.url then .LOGO = {
"@HREF": $channel.image.url,
"@STYLE": "IMAGE"
} else . end

View File

@ -62,7 +62,7 @@ def parse_date: ensure_string | strptime("%a, %d %b %Y %T %Z") | mktime | todate
]
}
| if $channel.language then .["@xml:lang"] = ($channel.language | ensure_string) else . end
| if $channel.image then .link += [{
| if $channel.image and $channel.image.url then .link += [{
"@rel": "logo",
# RSS does not provide an image's mime type, so we try to guess
"@type": ("image/" + ($channel.image.url | capture("\\.(?<ext>[a-zA-Z0-9]+)$").ext // "x-unknown")),

View File

@ -40,4 +40,4 @@ def ensure_array: (. // []) | if type == "array" then . else [.] end;
# Optional language
| if $channel.language then .language = $channel.language else . end
# Optional icon
| if $channel.image then .icon = $channel.image.url else . end
| if $channel.image and $channel.image.url then .icon = $channel.image.url else . end