Removing multiple relays in the same line.

This commit is contained in:
Vitor Pamplona
2025-08-23 10:49:40 -04:00
parent 356a805681
commit 36b14f93cb

View File

@@ -95,6 +95,14 @@ class RelayUrlNormalizer {
@OptIn(ExperimentalContracts::class)
fun fix(url: String): String? {
if (url.length < 3) return null
if (url.length > 100) {
// removes multiple urls in the same line
val schemeIdx = url.indexOf("://")
val nextScheme = url.indexOf("://", schemeIdx + 3)
if (nextScheme > 0) {
return null
}
}
val trimmed =
if (url[0].isWhitespace() || url[url.length - 1].isWhitespace()) {