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

mozilla / blurts-server / 00f7475d-b1a7-44af-928a-2bcf33438993

pending completion
00f7475d-b1a7-44af-928a-2bcf33438993

Pull #2989

circleci

Vincent
fixup! fixup! fixup! fixup! Store exposure scan data at OneRep
Pull Request #2989: Add API to store data to scan for exposures

282 of 1740 branches covered (16.21%)

Branch coverage included in aggregate %.

117 of 117 new or added lines in 9 files covered. (100.0%)

959 of 4624 relevant lines covered (20.74%)

3.46 hits per line

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

0.0
/src/utils/parse.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 {string} ISO8601DateString See https://en.wikipedia.org/wiki/ISO_8601
7
 * @typedef {`+${string}`} E164PhoneNumberString See https://en.wikipedia.org/wiki/E.164
8
 */
9

10
/**
11
 * @param {string} phoneNumber
12
 * @returns {E164PhoneNumberString | null}
13
 */
14
export function parseE164PhoneNumber (phoneNumber) {
15
  if (typeof phoneNumber !== 'string' || phoneNumber.length > 16 || !phoneNumber.startsWith('+')) {
×
16
    return null
×
17
  }
18

19
  const parsedNumber = /** @type {E164PhoneNumberString} */ ('+' + Number.parseInt(phoneNumber.substring(1), 10).toString())
×
20
  if (parsedNumber !== phoneNumber) {
×
21
    return null
×
22
  }
23

24
  return parsedNumber
×
25
}
26

27
/**
28
 * @param {ISO8601DateString} datetime
29
 * @returns {Date | null}
30
 */
31
export function parseIso8601Datetime (datetime) {
32
  if (typeof datetime !== 'string') {
×
33
    return null
×
34
  }
35

36
  // Important caveat to keep in mind:
37
  // > Support for ISO 8601 formats differs in that date-only strings
38
  // > (e.g. "1970-01-01") are treated as UTC, not local.
39
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#parameters
40
  try {
×
41
    return new Date(datetime)
×
42
  } catch (_e) {
43
    return null
×
44
  }
45
}
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