• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #13224

pending completion
#13224

push

circleci

flozia
Merge branch 'main' into MNTOR-971-Landing-page-transitions

282 of 1677 branches covered (16.82%)

Branch coverage included in aggregate %.

136 of 136 new or added lines in 15 files covered. (100.0%)

959 of 4545 relevant lines covered (21.1%)

1.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/utils/emailAddress.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
/**
6
 * @typedef {{ email: string; isValid: true }} ValidatedEmail An email address
7
 * that has been validated by {@see validateEmailAddress}. By turning this into
8
 * a separate type, functions can use this as an explicit argument to make sure
9
 * they are not passed unvalidated email addresses.
10
 */
11

12
/**
13
 * Validate an email address against the same RegEx that browsers use on input[type=email]
14
 *
15
 * See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#basic_validation
16
 *
17
 * @param {string} [userInput]
18
 * @returns {ValidatedEmail | null}
19
 */
20
export function validateEmailAddress (userInput) {
21
  if (typeof userInput === 'string' && emailRegex.test(userInput)) {
×
22
    return {
×
23
      isValid: true,
24
      email: userInput
25
    }
26
  }
27

28
  return null
×
29
}
30

31
/**
32
 * See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#basic_validation
33
 */
34
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc