mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-28 18:51:45 +01:00
Fixes #1084. Opengraph parser fails when value-less properties are present.
This commit is contained in:
parent
428ed464af
commit
28da06ef01
@ -78,4 +78,29 @@ class MetaTagsParserTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testParseWithAdditionalTags() {
|
||||||
|
val input =
|
||||||
|
"""<html>
|
||||||
|
| <head>
|
||||||
|
| <meta data-preact-helmet property="og:title" content="Uma conversa com Antonio Vargas">
|
||||||
|
| </head>
|
||||||
|
|</html>
|
||||||
|
""".trimMargin()
|
||||||
|
|
||||||
|
val exp =
|
||||||
|
listOf(
|
||||||
|
listOf("property" to "og:title", "content" to "Uma conversa com Antonio Vargas"),
|
||||||
|
)
|
||||||
|
|
||||||
|
val metaTags = MetaTagsParser.parse(input).toList()
|
||||||
|
println(metaTags)
|
||||||
|
assertEquals(exp.size, metaTags.size)
|
||||||
|
metaTags.zip(exp).forEach { (meta, expAttrs) ->
|
||||||
|
expAttrs.forEach { (name, expValue) ->
|
||||||
|
assertEquals(expValue, meta.attr(name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,14 @@ object MetaTagsParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.isWhitespace() -> {}
|
c.isWhitespace() -> {}
|
||||||
else -> return null
|
|
||||||
|
else -> {
|
||||||
|
// if it is expecting = but gets another name, starts another property
|
||||||
|
runCatching { attrs.add(Pair(input.slice(nameBegin..<nameEnd), "")) }
|
||||||
|
|
||||||
|
nameBegin = i
|
||||||
|
state = State.NAME
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user