mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Fixes #2618 - Allow dashes in room identifiers
This commit is contained in:
@@ -34,7 +34,7 @@ enum MatrixEntityRegex: String {
|
|||||||
case .roomAlias:
|
case .roomAlias:
|
||||||
return "#[A-Z0-9._%#@=+-]+:" + MatrixEntityRegex.homeserver.rawValue
|
return "#[A-Z0-9._%#@=+-]+:" + MatrixEntityRegex.homeserver.rawValue
|
||||||
case .roomId:
|
case .roomId:
|
||||||
return "![A-Z0-9]+:" + MatrixEntityRegex.homeserver.rawValue
|
return "![A-Z0-9_\\-\\/]+:" + MatrixEntityRegex.homeserver.rawValue
|
||||||
case .eventId:
|
case .eventId:
|
||||||
return "\\$[a-z0-9_\\-\\/]+(:[a-z0-9]+\\.[a-z0-9]+)?"
|
return "\\$[a-z0-9_\\-\\/]+(:[a-z0-9]+\\.[a-z0-9]+)?"
|
||||||
case .allUsers:
|
case .allUsers:
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class MatrixEntityRegexTests: XCTestCase {
|
|||||||
|
|
||||||
func testRoomId() {
|
func testRoomId() {
|
||||||
XCTAssertTrue(MatrixEntityRegex.isMatrixRoomIdentifier("!pMBteVpcoJRdCJxDmn:matrix.org"))
|
XCTAssertTrue(MatrixEntityRegex.isMatrixRoomIdentifier("!pMBteVpcoJRdCJxDmn:matrix.org"))
|
||||||
|
XCTAssertTrue(MatrixEntityRegex.isMatrixRoomIdentifier("!pMBte-Vpco-JRdCJxDmn:matrix.org"))
|
||||||
XCTAssertFalse(MatrixEntityRegex.isMatrixRoomIdentifier("pMBteVpcoJRdCJxDmn:matrix.org"))
|
XCTAssertFalse(MatrixEntityRegex.isMatrixRoomIdentifier("pMBteVpcoJRdCJxDmn:matrix.org"))
|
||||||
XCTAssertFalse(MatrixEntityRegex.isMatrixRoomIdentifier("!pMBteVpcoJRdCJxDmn.matrix.org"))
|
XCTAssertFalse(MatrixEntityRegex.isMatrixRoomIdentifier("!pMBteVpcoJRdCJxDmn.matrix.org"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,17 @@ class PermalinkBuilderTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testMautrixBridgePermalink() throws {
|
||||||
|
let roomId = "!mautrix-signal-v6:maunium.net"
|
||||||
|
|
||||||
|
do {
|
||||||
|
let permalink = try PermalinkBuilder.permalinkTo(roomIdentifier: roomId, baseURL: appSettings.permalinkBaseURL)
|
||||||
|
XCTAssertEqual(permalink, URL(string: "\(appSettings.permalinkBaseURL)/#/!mautrix-signal-v6%3Amaunium.net"))
|
||||||
|
} catch {
|
||||||
|
XCTFail("Room identifier must be valid: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testInvalidRoomIdentifier() {
|
func testInvalidRoomIdentifier() {
|
||||||
do {
|
do {
|
||||||
_ = try PermalinkBuilder.permalinkTo(roomIdentifier: "This1sN0tV4lid!@#$%^&*()", baseURL: appSettings.permalinkBaseURL)
|
_ = try PermalinkBuilder.permalinkTo(roomIdentifier: "This1sN0tV4lid!@#$%^&*()", baseURL: appSettings.permalinkBaseURL)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Fix room permalink building, allow dashes in room identifiers
|
||||||
Reference in New Issue
Block a user