From 11c9dfe7ffdc1980ec7fa75d42b4caf2331d7a87 Mon Sep 17 00:00:00 2001 From: mroxso <24775431+mroxso@users.noreply.github.com> Date: Fri, 25 Apr 2025 22:43:03 +0200 Subject: [PATCH] fix: Normalize relay URLs in connection check to improve accuracy (#97) Co-authored-by: highperfocused --- components/ManageCustomRelays.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/ManageCustomRelays.tsx b/components/ManageCustomRelays.tsx index ee19186..aad9a32 100644 --- a/components/ManageCustomRelays.tsx +++ b/components/ManageCustomRelays.tsx @@ -36,7 +36,14 @@ export function ManageCustomRelays() { // Check if a relay is currently connected const isConnected = (relayUrl: string) => { - return connectedRelays?.some(relay => relay.url === relayUrl && relay.status === 1) || false; + // Normalize the URL by removing trailing slash + const normalizedRelayUrl = relayUrl.endsWith('/') ? relayUrl.slice(0, -1) : relayUrl; + + return connectedRelays?.some(relay => { + // Normalize connected relay URL too + const normalizedConnectedUrl = relay.url.endsWith('/') ? relay.url.slice(0, -1) : relay.url; + return normalizedConnectedUrl === normalizedRelayUrl && relay.status === 1; + }) || false; }; if (customRelays.length === 0) {