Extend autolink parsing to handle non-HTTP links, add fallback for invalid autolinks, and update ParseTest coverage.

This commit is contained in:
2026-02-27 15:18:10 +01:00
parent bda99a5d56
commit f93a06451d
2 changed files with 6 additions and 2 deletions

View File

@@ -133,8 +133,12 @@ private val states = listOf(
if (content.contains("@") and content.contains(".")) {
Link("mailto:$content", content)
} else {
} else if (content.startsWith("http://") ||
content.startsWith("https://")
) {
Link(content, content)
} else {
Text("<$content>")
}
},

View File

@@ -398,7 +398,7 @@ class ParseTest {
@Test
fun testAutlinks() {
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()
val md = markdown(input)