relays: strip trailing / from relay urls

Fixes: https://github.com/damus-io/damus/issues/1443
Changelog-Fixed: Fix issue with slashes on relay urls causing relay connection problems
This commit is contained in:
William Casarin
2023-08-06 09:02:18 -07:00
parent a73271e3d4
commit d4faacb99f
3 changed files with 40 additions and 1 deletions

28
damusTests/UrlTests.swift Normal file
View File

@@ -0,0 +1,28 @@
//
// UrlTests.swift
// damusTests
//
// Created by William Casarin on 2023-08-06.
//
import XCTest
@testable import damus
final class UrlTests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testRelayUrlStripsEndingSlash() throws {
let url1 = RelayURL("wss://jb55.com/")!
let url2 = RelayURL("wss://jb55.com")!
XCTAssertEqual(url1, url2)
XCTAssertEqual(url1.url.absoluteString, "wss://jb55.com")
}
}