From b122408471f01148b6db4decf2d1c73f9474ed21 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Mon, 4 Nov 2024 11:37:52 -0300 Subject: [PATCH] Fix duplicated relay url --- .../java/com/greenart7c3/nostrsigner/models/BunkerRequest.kt | 4 +++- .../java/com/greenart7c3/nostrsigner/service/IntentUtils.kt | 4 +++- .../main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/models/BunkerRequest.kt b/app/src/main/java/com/greenart7c3/nostrsigner/models/BunkerRequest.kt index 09b82ece..855891fd 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/models/BunkerRequest.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/models/BunkerRequest.kt @@ -85,7 +85,9 @@ data class BunkerRequest( }.toTypedArray(), localKey = jsonObject.get("localKey")?.asText()?.intern() ?: "", relays = jsonObject.get("relays")?.asIterable()?.toList()?.map { - RelaySetupInfo(it.asText().intern(), read = true, write = true, feedTypes = COMMON_FEED_TYPES) + var relayUrl = it.asText().intern() + if (relayUrl.endsWith("/")) relayUrl = relayUrl.dropLast(1) + RelaySetupInfo(relayUrl, read = true, write = true, feedTypes = COMMON_FEED_TYPES) } ?: NostrSigner.getInstance().getSavedRelays().toList(), secret = jsonObject.get("secret")?.asText()?.intern() ?: "", currentAccount = jsonObject.get("currentAccount")?.asText()?.intern() ?: "", diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/service/IntentUtils.kt b/app/src/main/java/com/greenart7c3/nostrsigner/service/IntentUtils.kt index e20b6cf1..23aea172 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/IntentUtils.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/IntentUtils.kt @@ -806,8 +806,10 @@ object IntentUtils { if (index == 0) null else s }.joinToString { data -> data } if (paramName == "relay") { + var relayUrl = json + if (relayUrl.endsWith("/")) relayUrl = relayUrl.dropLast(1) relays.add( - RelaySetupInfo(json, read = true, write = true, feedTypes = COMMON_FEED_TYPES), + RelaySetupInfo(relayUrl, read = true, write = true, feedTypes = COMMON_FEED_TYPES), ) } if (paramName == "name") { diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt index 3946a486..fc9a3483 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt @@ -6,7 +6,6 @@ import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Build -import android.provider.Settings import android.util.Log import android.widget.Toast import androidx.activity.compose.ManagedActivityResultLauncher