check for localhost when adding a new relay

This commit is contained in:
greenart7c3
2024-06-26 16:33:24 -03:00
parent d6ab376f2d
commit e358387ba1

View File

@@ -31,7 +31,9 @@ class RelayUrlFormatter {
fun normalize(url: String): String {
val newUrl =
if (!url.startsWith("wss://") && !url.startsWith("ws://")) {
if (url.endsWith(".onion") || url.endsWith(".onion/")) {
// TODO: How to identify relays on the local network?
val isLocalHost = url.contains("127.0.0.1") || url.contains("localhost")
if (url.endsWith(".onion") || url.endsWith(".onion/") || isLocalHost) {
"ws://${url.trim()}"
} else {
"wss://${url.trim()}"