diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/richtext/UrlParserTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/richtext/UrlParserTest.kt index 8777f5329..600c0f27f 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/richtext/UrlParserTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/richtext/UrlParserTest.kt @@ -293,18 +293,6 @@ class UrlParserTest { Urls(), ) - /** - * Regression test for PR #1907: a URL that ends with ':' causes readEnd() to trim it, - * but the PORT marker index was already set to buffer.length (one past the trimmed URL). - * Accessing host/port must not throw StringIndexOutOfBoundsException. - */ - @Test - fun testUrlEndingWithColon() = - test( - "example.com:", - Urls(), - ) - @Test fun testHour() = test( diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip10Notes/urls/UrlsDetectorTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip10Notes/urls/UrlsDetectorTest.kt index 7e7f66d24..aae685bf2 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip10Notes/urls/UrlsDetectorTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip10Notes/urls/UrlsDetectorTest.kt @@ -51,15 +51,4 @@ class UrlsDetectorTest { val detectedLinks = fastFindURLs("今北産業") assertEquals(0, detectedLinks.size) } - - /** - * Regression test for PR #1907: a bare host ending with ':' triggers PORT marker placement - * at buffer.length, then readEnd() trims the ':', leaving PORT beyond the URL string. - * Url.getPart() must not throw StringIndexOutOfBoundsException. - */ - @Test - fun doesNotCrashOnUrlEndingWithColon() { - // Just verifying no exception is thrown; a bare "example.com:" is not a valid URL. - fastFindURLs("example.com:") - } } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/urldetector/UrlMarkerTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/urldetector/UrlMarkerTest.kt index 2c9bd35cb..b13e3b658 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/urldetector/UrlMarkerTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/urldetector/UrlMarkerTest.kt @@ -319,67 +319,4 @@ class UrlMarkerTest { intArrayOf(0, 8, 18, 33, 35, 36, 53), ) - /** - * Regression test for PR #1907: StringIndexOutOfBoundsException in Url.getPart() when a URL - * ending with a character in CANNOT_END_URLS_WITH (e.g. ':') is trimmed by readEnd(), but the - * urlMarker PORT index was set to buffer.length (one past the last valid index). - * - * After trimming, PORT index == originalUrl.length, so getPart(PORT) must return null - * and getPart(HOST) must clamp endIndex to originalUrl.length via minOf. - * - * Simulates what happens when "example.com:" is detected: the ':' is trimmed to produce - * "example.com" but PORT marker remains at index 11 (= trimmed string length). - */ - @Test - fun testPortIndexAtStringLength() = - testUrlMarker( - "example.com", // 11 chars – simulates "example.com:" after trailing ':' is trimmed - "https", - "", - "", - "example.com", // host must not throw; endIndex clamped by minOf - -1, // PORT at index 11 == length → getPart returns null → falls back to scheme default → 443, but no scheme → -1 - "/", - "", - "", - intArrayOf(-1, -1, 0, 11, -1, -1, -1), // HOST=0, PORT=11 (= string length) - ) - - /** - * Regression test for PR #1907: PORT index beyond the end of the trimmed URL. - * Simulates a marker that points one position past the string length. - */ - @Test - fun testPortIndexBeyondStringLength() = - testUrlMarker( - "example.com", // 11 chars - "https", - "", - "", - "example.com", // host must not throw - -1, // PORT at 12 > length → getPart(PORT) returns null → -1 - "/", - "", - "", - intArrayOf(-1, -1, 0, 12, -1, -1, -1), // PORT=12 > string length 11 - ) - - /** - * Regression test for PR #1907: QUERY index at string length (simulates "example.com/path?" - * after trailing '?' is trimmed, leaving urlMarker QUERY at the trimmed string's length). - */ - @Test - fun testQueryIndexAtStringLength() = - testUrlMarker( - "example.com/path", // 16 chars – simulates "example.com/path?" after '?' trimmed - "https", - "", - "", - "example.com", - 443, - "/path", // path must not throw; endIndex clamped by minOf - "", // QUERY at 16 == length → getPart(QUERY) returns null - "", - intArrayOf(-1, -1, 0, -1, 11, 16, -1), // HOST=0, PATH=11, QUERY=16 (= string length) - ) }