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

mozilla / blurts-server / #13258

pending completion
#13258

push

circleci

Vinnl
Update filter results when clearing search field

On the public breach list, the search input that filters the list
of breaches would respond to `keyup` events specifically, rather
than anything that might change the input. Thus, if (e.g. in Chrome
or Safari) a browser adds a "Clear input" icon to the field and the
user clicks that, the field gets emptied, but the list of breaches
are still narrowed down to the previous input.

282 of 1663 branches covered (16.96%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

959 of 4511 relevant lines covered (21.26%)

1.77 hits per line

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

0.0
/controllers/ip-location.js
1
// IP location data includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com.
2
// For testing, you can compare IPs to the corresponding json, eg: https://github.com/maxmind/MaxMind-DB/blob/main/source-data/GeoLite2-City-Test.json
3

4
'use strict'
5

6
const AppConstants = require('../app-constants')
×
7
const { readLocationData } = require('../ip-location-service')
×
8

9
async function getIpLocation (req, res) {
10
  let clientIp
11

12
  switch (AppConstants.NODE_ENV) {
×
13
    case 'dev':
14
      clientIp = req.headers['test-ip'] || '216.160.83.56' // fallback an IP that exists in limited/local GeoLite2 test DB
×
15
      break
×
16
    case 'heroku':
17
    case 'stage':
18
      clientIp = req.headers['test-ip'] || req.ip // Use "test-ip" header if available, fallback to original IP
×
19
      break
×
20
    default:
21
      clientIp = req.ip
×
22
  }
23

24
  if (clientIp === req.session.locationData?.clientIp) {
×
25
    return res.status(200).json(req.session.locationData) // return cached data
×
26
  }
27

28
  const locationData = await readLocationData(clientIp, req.supportedLocales)
×
29

30
  if (locationData) {
×
31
    req.session.locationData = Object.assign(locationData, { clientIp }) // cache new location data, adding clientIP key
×
32
    return res.status(200).json(req.session.locationData)
×
33
  }
34

35
  return res.status(200).json({ clientIp })
×
36
}
37

38
module.exports = {
×
39
  getIpLocation
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