Fixed matrix_user_id
regex (#4312)
* fix(matrix_user_id): fixed regex * test(matrix_user_id): added test with underscore
This commit is contained in:
parent
4ef00e068f
commit
f223eb94d5
1 changed files with 2 additions and 1 deletions
|
@ -6,7 +6,7 @@ use url::Url;
|
|||
|
||||
// From here: https://github.com/vector-im/element-android/blob/develop/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixPatterns.kt#L35
|
||||
static VALID_MATRIX_ID_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||
Regex::new(r"^@[A-Za-z0-9\\x21-\\x39\\x3B-\\x7F]+:[A-Za-z0-9.-]+(:[0-9]{2,5})?$")
|
||||
Regex::new(r"^@[A-Za-z0-9\x21-\x39\x3B-\x7F]+:[A-Za-z0-9.-]+(:[0-9]{2,5})?$")
|
||||
.expect("compile regex")
|
||||
});
|
||||
// taken from https://en.wikipedia.org/wiki/UTM_parameters
|
||||
|
@ -386,6 +386,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_valid_matrix_id() {
|
||||
assert!(is_valid_matrix_id("@dess:matrix.org").is_ok());
|
||||
assert!(is_valid_matrix_id("@dess_:matrix.org").is_ok());
|
||||
assert!(is_valid_matrix_id("@dess:matrix.org:443").is_ok());
|
||||
assert!(is_valid_matrix_id("dess:matrix.org").is_err());
|
||||
assert!(is_valid_matrix_id(" @dess:matrix.org").is_err());
|
||||
|
|
Loading…
Reference in a new issue