damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit bd94b76d1ef9741ff1a16e2a9bebeaa3b97da1d6
parent 5fa138d05021134d9a6cb1ba16d4f726d59c8a82
Author: Daniel D’Aquino <daniel@daquino.me>
Date:   Wed,  4 Oct 2023 22:12:24 +0000

ui: remove unnecessary url string manipulations

This is a follow up commit to `768ab3e9e4f55b872253d55c53983c19ab4c3d8b` in issue #1531

Testing
-------

**Device:** iPhone 14 Pro simulator
**iOS:** 17.0
**Damus:** This commit

**Steps:**
1. Remove all relays.
2. Add the Damus relay.
3. Add `wss://relay.snort.social/` relay **(with trailing slash)**. Shows up on the relay list. (PASS)
4. Add `wss://relay.snort.social/v1` and `wss://relay.snort.social/v2` to the list. Both show up as separate relays (PASS)
4. Watch logs and wait for the relay list event to be sent out
5. Restart Damus (to help ensure the repro is stable)
6. Try removing the Snort relay by swiping. Relay is removed successfully (PASS)
7. Try removing the "v1" relay by clicking on "Disconnect relay" in the detail page. "v1" relay (and NOT "v2") is removed (PASS)
8. Try adding `nos.lol` from the recommended list. Added successfully. (PASS)
9. Remove `nos.lol` with a long press. (PASS)

Changelog-Fixed: Fix issue where relays with trailing slashes cannot be removed (#1531)
Closes: https://github.com/damus-io/damus/issues/1531
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Nostr/RelayURL.swift | 7+------
Mdamus/Views/AddRelayView.swift | 6------
2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/damus/Nostr/RelayURL.swift b/damus/Nostr/RelayURL.swift @@ -17,12 +17,7 @@ public struct RelayURL: Hashable, Equatable, Codable, CodingKeyRepresentable { init?(_ str: String) { guard let last = str.last else { return nil } - var urlstr = str - if last == "/" { - urlstr = String(str.dropLast(1)) - } - - guard let url = URL(string: urlstr) else { + guard let url = URL(string: str) else { return nil } diff --git a/damus/Views/AddRelayView.swift b/damus/Views/AddRelayView.swift @@ -82,12 +82,6 @@ struct AddRelayView: View { new_relay = "wss://" + new_relay } - /* - if new_relay.hasSuffix("/") { - new_relay.removeLast(); - } - */ - guard let url = RelayURL(new_relay), let ev = state.contacts.event, let keypair = state.keypair.to_full() else {