From 672f471e12ab6dc8c10029f9ca3808c9d4f92145 Mon Sep 17 00:00:00 2001 From: LA <72925898+Liquid-Aristocracy@users.noreply.github.com> Date: Sat, 15 Oct 2022 20:09:29 +0800 Subject: [PATCH] Fix parsing of srcset images (#241) --- .../ash/reader/ui/component/reader/HtmlToComposable.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/me/ash/reader/ui/component/reader/HtmlToComposable.kt b/app/src/main/java/me/ash/reader/ui/component/reader/HtmlToComposable.kt index a5552fc..7681321 100644 --- a/app/src/main/java/me/ash/reader/ui/component/reader/HtmlToComposable.kt +++ b/app/src/main/java/me/ash/reader/ui/component/reader/HtmlToComposable.kt @@ -755,7 +755,7 @@ internal class ImageCandidates( * Might throw if hasImage returns false */ fun getBestImageForMaxSize(maxSize: Size, pixelDensity: Float): String { - val setCandidate = srcSet.splitToSequence(",") + val setCandidate = srcSet.splitToSequence(", ") .map { it.trim() } .map { it.split(SpaceRegex).take(2).map { x -> x.trim() } } .fold(100f to "") { acc, candidate -> @@ -787,10 +787,10 @@ internal class ImageCandidates( } .second - if (setCandidate.isNotBlank()) { - return StringUtil.resolve(baseUrl, setCandidate) - } - return StringUtil.resolve(baseUrl, absSrc) + return StringUtil.resolve( + baseUrl, + setCandidate.takeIf { it.isNotBlank() } ?: absSrc + ) } }