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

mozilla / blurts-server / 91d6cb3f-fc59-4d91-b83e-160bcd685142

pending completion
91d6cb3f-fc59-4d91-b83e-160bcd685142

push

circleci

GitHub
Merge pull request #2917 from mozilla/MNTOR-1343-breach-page-styling

282 of 1595 branches covered (17.68%)

Branch coverage included in aggregate %.

96 of 96 new or added lines in 10 files covered. (100.0%)

959 of 4309 relevant lines covered (22.26%)

3.7 hits per line

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

0.0
/src/utils/breach-logo.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
 * @param {object} breach
7
 * @param {Map<string, string>} logos Map of URLs to logos indexed by the domain name of the respective company
8
 * @returns {string} HTML for a breach logo (either an `img`, or a `span.breach-logo` containing the breached company's first letter)
9
 */
10
export function getBreachLogo (breach, logos) {
11
  const logo = logos.has(breach.Domain)
×
12
    ? `<img src='${logos.get(breach.Domain)}' alt='' loading="lazy" class='breach-logo' height='32' />`
13
    : `<span role="img" aria-hidden='true' class='breach-logo' style='background-color: var(${getColorForName(breach.Name)});'>${breach.Name.substring(0, 1)}</span>`
14

15
  return logo
×
16
}
17

18
/**
19
 * @param {string} name
20
 * @returns string CSS variable for a string-specific color
21
 */
22
function getColorForName (name) {
23
  const logoColors = [
×
24
    '--blue-5',
25
    '--purple-5',
26
    '--green-05',
27
    '--violet-5',
28
    '--orange-5',
29
    '--yellow-5',
30
    '--red-5',
31
    '--pink-5'
32
  ]
33

34
  const charValue = name
×
35
    .split('')
36
    .map(letter => letter.codePointAt(0))
×
37
    .reduce((sum, codePoint) => sum + codePoint)
×
38

39
  return logoColors[charValue % logoColors.length]
×
40
}
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