diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/previews/UrlPreviewUtils.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/previews/UrlPreviewUtils.kt index 354be00cd..d8cc1d0c7 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/previews/UrlPreviewUtils.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/previews/UrlPreviewUtils.kt @@ -12,18 +12,9 @@ private const val ATTRIBUTE_VALUE_PROPERTY = "property" private const val ATTRIBUTE_VALUE_NAME = "name" private const val ATTRIBUTE_VALUE_ITEMPROP = "itemprop" -/* for if (title.isEmpty()) title = it.attr(CONTENT) - in META_OG_DESCRIPTION -> if (description.isEmpty()) { + when (it.attr(ATTRIBUTE_VALUE_PROPERTY)) { + in META_X_TITLE -> if (title.isEmpty()) { + title = it.attr(CONTENT) + } + in META_X_DESCRIPTION -> if (description.isEmpty()) { description = it.attr(CONTENT) } - in META_OG_IMAGE -> if (image.isEmpty()) image = it.attr(CONTENT) + in META_X_IMAGE -> if (image.isEmpty()) { + image = it.attr(CONTENT) + } } when (it.attr(ATTRIBUTE_VALUE_NAME)) { - in META_NAME_TITLE -> if (title.isEmpty()) title = it.attr(CONTENT) - in META_NAME_DESCRIPTION -> if (description.isEmpty()) { + in META_X_TITLE -> if (title.isEmpty()) { + title = it.attr(CONTENT) + } + in META_X_DESCRIPTION -> if (description.isEmpty()) { description = it.attr(CONTENT) } - in META_OG_IMAGE -> if (image.isEmpty()) image = it.attr(CONTENT) + in META_X_IMAGE -> if (image.isEmpty()) { + image = it.attr(CONTENT) + } } when (it.attr(ATTRIBUTE_VALUE_ITEMPROP)) { - in META_ITEMPROP_TITLE -> if (title.isEmpty()) { + in META_X_TITLE -> if (title.isEmpty()) { title = it.attr(CONTENT) } - in META_ITEMPROP_DESCRIPTION -> if (description.isEmpty()) { + in META_X_DESCRIPTION -> if (description.isEmpty()) { description = it.attr(CONTENT) } - in META_ITEMPROP_IMAGE -> if (image.isEmpty()) { + in META_X_IMAGE -> if (image.isEmpty()) { image = it.attr(CONTENT) } }