Beam/ElementX/Sources/Other/MatrixEntityRegex.swift
Doug 26d8affaa8
#40: Add basic AuthenticationService and missing UI tests.
* Add MockAuthenticationService and ServerSelectionUITests.
* Add tests covering the Authentication flow.
2022-07-04 10:00:27 +01:00

33 lines
865 B
Swift

//
// MatrixEntitityRegex.swift
// ElementX
//
// Created by Stefan Ceriu on 26/03/2022.
// Copyright © 2022 Element. All rights reserved.
//
import Foundation
enum MatrixEntityRegex: String {
case homeserver
case userId
case roomAlias
case roomId
case eventId
var rawValue: String {
switch self {
case .homeserver:
return "[A-Z0-9]+((\\.|\\-)[A-Z0-9]+){0,}(:[0-9]{2,5})?"
case .userId:
return "@[\\x21-\\x39\\x3B-\\x7F]+:" + MatrixEntityRegex.homeserver.rawValue
case .roomAlias:
return "#[A-Z0-9._%#@=+-]+:" + MatrixEntityRegex.homeserver.rawValue
case .roomId:
return "![A-Z0-9]+:" + MatrixEntityRegex.homeserver.rawValue
case .eventId:
return "\\$[A-Z0-9]+:" + MatrixEntityRegex.homeserver.rawValue
}
}
}