package net.sergeych.toread

import kotlin.test.Test
import kotlin.test.assertEquals

class ReaderLinkDetectionTest {
    @Test
    fun detectsWebUrlsAndTrimsSentencePunctuation() {
        val text = "See http://example.org/path?q=1, then https://site.test/end."

        val urls = text.webUrlRanges().map { text.substring(it) }

        assertEquals(listOf("http://example.org/path?q=1", "https://site.test/end"), urls)
    }

    @Test
    fun ignoresNonWebUrls() {
        val text = "ftp://files.test https://secure.test"

        val urls = text.webUrlRanges().map { text.substring(it) }

        assertEquals(listOf("https://secure.test"), urls)
    }
}
