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

nilfalse / ctf / 3755652913

pending completion
3755652913

Pull #260

github

GitHub
Merge 417ca3d21 into f03cdd64f
Pull Request #260: Update prettier: 2.6.2 → 2.8.1 (minor)

224 of 266 branches covered (84.21%)

Branch coverage included in aggregate %.

563 of 613 relevant lines covered (91.84%)

71.14 hits per line

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

81.82
/packages/runtime/interceptors/ip.ts
1
import { Request } from '../lib/request';
2
import { db } from '../services/geo/geo_service';
3

4
import { Match } from './_common';
5

6
export interface IPMatch extends Match {
7
  heuristic: 'ip';
8
  extra: { registeredCountry: string } | null;
9
}
10

11
// eslint-disable-next-line @typescript-eslint/require-await
12
export async function dispatch({
13
  ip,
14
}: Request): Promise<ReadonlyArray<IPMatch>> {
15
  if (!ip) {
21✔
16
    return [];
5✔
17
  }
18

19
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20
  const countryResponse = db!.get(ip);
16✔
21
  if (!countryResponse) {
16!
22
    return [];
×
23
  }
24

25
  const result = [];
16✔
26
  const { country, registered_country: registeredCountry } = countryResponse;
16✔
27
  if (country) {
16✔
28
    const continent = countryResponse.continent
15!
29
      ? countryResponse.continent.code
30
      : null;
31

32
    const extra = registeredCountry
15!
33
      ? {
34
          registeredCountry: registeredCountry.iso_code,
35
        }
36
      : null;
37

38
    result.push({
15✔
39
      heuristic: 'ip' as const,
40

41
      score: 0.5,
42
      isoCountry: country.iso_code,
43
      isoRegion: null,
44
      continent,
45
      extra,
46
    });
47
  }
48

49
  return result;
16✔
50
}
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