Fix parsing of srcset images (#241)
This commit is contained in:
parent
ea0e8d5e3c
commit
672f471e12
|
@ -755,7 +755,7 @@ internal class ImageCandidates(
|
||||||
* Might throw if hasImage returns false
|
* Might throw if hasImage returns false
|
||||||
*/
|
*/
|
||||||
fun getBestImageForMaxSize(maxSize: Size, pixelDensity: Float): String {
|
fun getBestImageForMaxSize(maxSize: Size, pixelDensity: Float): String {
|
||||||
val setCandidate = srcSet.splitToSequence(",")
|
val setCandidate = srcSet.splitToSequence(", ")
|
||||||
.map { it.trim() }
|
.map { it.trim() }
|
||||||
.map { it.split(SpaceRegex).take(2).map { x -> x.trim() } }
|
.map { it.split(SpaceRegex).take(2).map { x -> x.trim() } }
|
||||||
.fold(100f to "") { acc, candidate ->
|
.fold(100f to "") { acc, candidate ->
|
||||||
|
@ -787,10 +787,10 @@ internal class ImageCandidates(
|
||||||
}
|
}
|
||||||
.second
|
.second
|
||||||
|
|
||||||
if (setCandidate.isNotBlank()) {
|
return StringUtil.resolve(
|
||||||
return StringUtil.resolve(baseUrl, setCandidate)
|
baseUrl,
|
||||||
}
|
setCandidate.takeIf { it.isNotBlank() } ?: absSrc
|
||||||
return StringUtil.resolve(baseUrl, absSrc)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user