1
0
mirror of git://jb55.com/damus synced 2024-10-01 09:20:47 +00:00

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>
This commit is contained in:
Daniel D’Aquino 2023-10-04 22:12:24 +00:00 committed by William Casarin
parent 5fa138d050
commit bd94b76d1e
2 changed files with 1 additions and 12 deletions

View File

@ -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
}

View File

@ -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 {