Skip to content

Commit b030170

Browse files
committed
feat: lowercase matched emails
1 parent 51332a9 commit b030170

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

.README/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ extractEmail('extracts emails surrounded by odd unicode characters, e.g. 邮箱
4545
extractEmail('extracts emails surrounded by emojis, e.g. 📧gajus@gajus.com');
4646
// [{email: 'gajus@gajus.com'}]
4747

48+
extractEmail('lowercases emails, e.g. GAJUS@GAJUS.COM');
49+
// [{email: 'gajus@gajus.com'}]
50+
4851
extractEmail('excludes invalid emails with invalid TLDs, e.g. gajus@gajus.png');
4952
// []
5053

src/normalizeInput.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ export default (input: string): string => {
1919

2020
// Matches all ASCII characters from the space to tilde.
2121
.replace(/[^ -~]/g, ' ')
22-
.trim();
22+
.trim()
23+
.toLowerCase();
2324
};

test/extract-email-address/extractEmail.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import extractEmail from '../../src/extractEmail';
55

66
const fixtures = [
77
'gajus@gajus.com',
8+
'GAJUS@GAJUS.COM',
89
':gajus@gajus.com',
910
'📧gajus@gajus.com',
1011
'gajus@gajus.com.',

test/extract-email-address/normalizeInput.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import test from 'ava';
44
import normalizeInput from '../../src/normalizeInput';
55

66
test('normalizes different email formats', (t) => {
7+
t.is(normalizeInput('GAJUS@GAJUS.COM'), 'gajus@gajus.com');
78
t.is(normalizeInput(':gajus@gajus.com'), 'gajus@gajus.com');
89
t.is(normalizeInput('📧gajus@gajus.com'), 'gajus@gajus.com');
910
t.is(normalizeInput('g a j u s [at] g a j u s [dot] c o m'), 'gajus@gajus.com');

0 commit comments

Comments
 (0)