Skip to content

Commit

Permalink
ui: remove unnecessary url string manipulations
Browse files Browse the repository at this point in the history
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: #1531
Signed-off-by: Daniel D’Aquino <[email protected]>
Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
danieldaquino authored and jb55 committed Oct 4, 2023
1 parent 5fa138d commit bd94b76
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
7 changes: 1 addition & 6 deletions damus/Nostr/RelayURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 0 additions & 6 deletions damus/Views/AddRelayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bd94b76

Please sign in to comment.