@@ -82,13 +82,27 @@ static HIDDEN_CHARACTERS_REGEX: Lazy<Regex> = Lazy::new(|| {
82
82
Regex :: new ( DisplayName :: HIDDEN_CHARACTERS_PATTERN )
83
83
. expect ( "We should be able to create a regex from our static hidden characters pattern" )
84
84
} ) ;
85
+
86
+ /// Regex to match `i` characters.
87
+ ///
88
+ /// This is used to replace an `i` with a lowercase `l`, i.e. to mark "Hello"
89
+ /// and "HeIlo" as ambiguous. Decancer will lowercase an `I` for us.
85
90
static I_REGEX : Lazy < Regex > = Lazy :: new ( || {
86
- Regex :: new ( DisplayName :: I_PATTERN )
87
- . expect ( "We should be able to create a regex from our uppercase I pattern" )
91
+ Regex :: new ( "[i]" ) . expect ( "We should be able to create a regex from our uppercase I pattern" )
88
92
} ) ;
93
+
94
+ /// Regex to match `0` characters.
95
+ ///
96
+ /// This is used to replace an `0` with a lowercase `o`, i.e. to mark "HellO"
97
+ /// and "Hell0" as ambiguous. Decancer will lowercase an `O` for us.
89
98
static ZERO_REGEX : Lazy < Regex > = Lazy :: new ( || {
90
99
Regex :: new ( "[0]" ) . expect ( "We should be able to create a regex from our zero pattern" )
91
100
} ) ;
101
+
102
+ /// Regex to match a couple of dot-like characters, also matches an actual dot.
103
+ ///
104
+ /// This is used to replace a `.` with a `:`, i.e. to mark "@mxid.domain.tld" as
105
+ /// ambiguous.
92
106
static DOT_REGEX : Lazy < Regex > = Lazy :: new ( || {
93
107
Regex :: new ( "[.\u{1d16d} ]" ) . expect ( "We should be able to create a regex from our dot pattern" )
94
108
} ) ;
@@ -165,12 +179,6 @@ impl DisplayName {
165
179
const HIDDEN_CHARACTERS_PATTERN : & str =
166
180
"[\u{2000} -\u{200D} \u{300} -\u{036f} \u{2062} -\u{2063} \u{2800} \u{061c} \u{feff} ]" ;
167
181
168
- /// Regex pattern to match `i` characters (upper and lower case).
169
- ///
170
- /// This is used to replace an uppercase I with a lowercase l, i.e. to mark
171
- /// "Hello" and "HeIlo" as ambiguous.
172
- const I_PATTERN : & str = "[Ii]" ;
173
-
174
182
/// Creates a new [`DisplayName`] from the given raw string.
175
183
///
176
184
/// The raw display name is transformed into a Unicode-normalized form, with
0 commit comments