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(".")) {
|
||||
Link("mailto:$content", content)
|
||||
} else {
|
||||
} else if (content.startsWith("http://") ||
|
||||
content.startsWith("https://")
|
||||
) {
|
||||
Link(content, content)
|
||||
} else {
|
||||
Text("<$content>")
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user