Skip to content

Commit aacbdb3

Browse files
authored
Merge pull request #1283 from epage/email
fix(token): Improve email detection by prefering that over base64
2 parents 6f0717a + e30fd36 commit aacbdb3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/typos/src/tokens.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ mod parser {
188188
// - Update `is_ignore_char` to make sure `sep1` doesn't eat it all up
189189
// - Make sure you always consume it
190190
terminated(uuid_literal, peek(sep1)),
191-
terminated(hash_literal, peek(sep1)),
191+
terminated(email_literal, peek(sep1)),
192+
terminated(url_literal, peek(sep1)),
193+
terminated(jwt, peek(sep1)),
192194
terminated(base64_literal, peek(sep1)), // base64 should be quoted or something
195+
terminated(hash_literal, peek(sep1)),
193196
terminated(ordinal_literal, peek(sep1)),
194197
terminated(hex_literal, peek(sep1)),
195198
terminated(dec_literal, peek(sep1)), // Allow digit-prefixed words
196-
terminated(email_literal, peek(sep1)),
197-
terminated(url_literal, peek(sep1)),
198199
terminated(css_color, peek(sep1)),
199-
terminated(jwt, peek(sep1)),
200200
c_escape,
201201
printf,
202202
other,
@@ -1653,7 +1653,7 @@ mod test {
16531653
fn tokenize_ignore_email() {
16541654
let parser = TokenizerBuilder::new().build();
16551655

1656-
let input = "Good [email protected] Bye";
1656+
let input = "Good [email protected] if=@nam iff=@nam Bye";
16571657
let actual: Vec<_> = parser.parse_bytes(input.as_bytes()).collect();
16581658
assert_data_eq!(
16591659
actual.to_debug(),
@@ -1667,7 +1667,7 @@ mod test {
16671667
Identifier {
16681668
token: "Bye",
16691669
case: None,
1670-
offset: 25,
1670+
offset: 42,
16711671
},
16721672
]
16731673
@@ -1686,7 +1686,7 @@ mod test {
16861686
Identifier {
16871687
token: "Bye",
16881688
case: None,
1689-
offset: 25,
1689+
offset: 42,
16901690
},
16911691
]
16921692

0 commit comments

Comments
 (0)