Skip to content

Commit

Permalink
fixup! feat(base): Introduce a DisplayName struct
Browse files Browse the repository at this point in the history
  • Loading branch information
poljar committed Nov 12, 2024
1 parent 5a61e07 commit 8069cd3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/matrix-sdk-base/src/deserialized_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub struct AmbiguityChanges {
/// # use matrix_sdk_base::deserialized_responses::DisplayName;
/// let display_name = DisplayName::new("@alice:localhost");
///
/// // The display name looks like na MXID, it's ambiguous because of that.
/// // The display name looks like an MXID, it's ambiguous because of that.
/// assert!(display_name.is_ambiguous());
/// ```
#[derive(Debug, Clone, Eq)]
Expand Down Expand Up @@ -149,7 +149,7 @@ impl DisplayName {
Regex::new(DisplayName::MXID_PATTERN)
.expect("We should be able to create a regex from our static MXID pattern")
});
const LEFT_RO_RIGHT_REGEX: Lazy<Regex> = Lazy::new(|| {
const LEFT_TO_RIGHT_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(DisplayName::LEFT_TO_RIGHT_PATTERN)
.expect("We should be able to create a regex from our static left-to-right pattern")
});
Expand All @@ -173,7 +173,7 @@ impl DisplayName {

let decancered = decancer::cure!(&replaced)
.ok()
.map(|cured| Self::LEFT_RO_RIGHT_REGEX.replace_all(cured.as_ref(), "").to_string());
.map(|cured| Self::LEFT_TO_RIGHT_REGEX.replace_all(cured.as_ref(), "").to_string());

Self { raw: raw.to_owned(), decancered }
}
Expand Down Expand Up @@ -226,7 +226,7 @@ impl DisplayName {
}

fn has_left_to_right_characters(&self) -> bool {
Self::LEFT_RO_RIGHT_REGEX.is_match(&self.raw)
Self::LEFT_TO_RIGHT_REGEX.is_match(&self.raw)
}

fn might_look_like_an_mxid(&self) -> bool {
Expand Down

0 comments on commit 8069cd3

Please sign in to comment.