mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
accessibility improvements + tests refinement
This commit is contained in:
@@ -14,6 +14,7 @@ enum MatrixEntityRegex: String {
|
||||
case roomAlias
|
||||
case uri
|
||||
case allUsers
|
||||
case legacyRoomID
|
||||
|
||||
var rawValue: String {
|
||||
switch self {
|
||||
@@ -23,6 +24,8 @@ enum MatrixEntityRegex: String {
|
||||
return "@[\\x21-\\x39\\x3B-\\x7F]+:" + MatrixEntityRegex.homeserver.rawValue
|
||||
case .roomAlias:
|
||||
return "#[A-Z0-9._%#@=+-]+:" + MatrixEntityRegex.homeserver.rawValue
|
||||
case .legacyRoomID:
|
||||
return "![A-Z0-9_\\-\\/]+:" + MatrixEntityRegex.homeserver.rawValue
|
||||
case .uri:
|
||||
return "matrix:(r|u|roomid)\\/[A-Z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=%]*(?:\\?[A-Z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=%]*)?"
|
||||
case .allUsers:
|
||||
@@ -37,6 +40,7 @@ enum MatrixEntityRegex: String {
|
||||
static let uriRegex = try! NSRegularExpression(pattern: MatrixEntityRegex.uri.rawValue, options: .caseInsensitive)
|
||||
static let allUsersRegex = try! NSRegularExpression(pattern: MatrixEntityRegex.allUsers.rawValue)
|
||||
static let linkRegex = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
|
||||
static let legacyRoomIDRegex = try! NSRegularExpression(pattern: MatrixEntityRegex.legacyRoomID.rawValue, options: .caseInsensitive)
|
||||
// swiftlint:enable force_try
|
||||
|
||||
static func isMatrixHomeserver(_ homeserver: String) -> Bool {
|
||||
@@ -63,6 +67,14 @@ enum MatrixEntityRegex: String {
|
||||
return match.range.length == alias.count
|
||||
}
|
||||
|
||||
static func isLegacyMatrixRoomID(_ roomID: String) -> Bool {
|
||||
guard let match = legacyRoomIDRegex.firstMatch(in: roomID) else {
|
||||
return false
|
||||
}
|
||||
|
||||
return match.range.length == roomID.count
|
||||
}
|
||||
|
||||
static func isMatrixURI(_ uri: String) -> Bool {
|
||||
guard let match = uriRegex.firstMatch(in: uri) else {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user