generated from rnentjes/kotlin-server-web-empty
Extend autolink parsing to handle non-HTTP links, add fallback for invalid autolinks, and update ParseTest coverage.
This commit is contained in:
@@ -133,8 +133,12 @@ private val states = listOf(
|
|||||||
|
|
||||||
if (content.contains("@") and content.contains(".")) {
|
if (content.contains("@") and content.contains(".")) {
|
||||||
Link("mailto:$content", content)
|
Link("mailto:$content", content)
|
||||||
} else {
|
} else if (content.startsWith("http://") ||
|
||||||
|
content.startsWith("https://")
|
||||||
|
) {
|
||||||
Link(content, content)
|
Link(content, content)
|
||||||
|
} else {
|
||||||
|
Text("<$content>")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ class ParseTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testAutlinks() {
|
fun testAutlinks() {
|
||||||
val input = """
|
val input = """
|
||||||
Dit is een text met <info@example.com> mail autolink and <http://www.nu.nl> http autolink.
|
Dit is een text met <info@example.com> mail autolink and <http://www.nu.nl> http autolink and <nonsense> autolink.
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
val md = markdown(input)
|
val md = markdown(input)
|
||||||
|
|||||||
Reference in New Issue
Block a user