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

ota-meshi / eslint-plugin-json-schema-validator / 21107985100

18 Jan 2026 07:21AM UTC coverage: 78.196% (-9.2%) from 87.363%
21107985100

Pull #452

github

web-flow
Merge 3cb189b5f into bb8e97af5
Pull Request #452: Bundle using tsdown

717 of 872 branches covered (82.22%)

Branch coverage included in aggregate %.

30 of 51 new or added lines in 7 files covered. (58.82%)

574 existing lines in 11 files now uncovered.

2170 of 2820 relevant lines covered (76.95%)

55.12 hits per line

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

48.82
/src/utils/http-client/get-modules/http.ts
1
import type { RequestOptions } from "https";
1✔
2
import https from "https";
1✔
3
import http from "http";
1✔
4
// @ts-expect-error -- no types
1✔
5
import tunnel from "tunnel-agent";
1✔
6

1✔
7
const TIMEOUT = 60000;
18✔
8

18✔
9
/**
18✔
10
 * GET Method using http modules.
18✔
11
 */
18✔
12
export default function get(
18✔
13
  url: string,
3✔
14
  options?: RequestOptions,
3✔
15
): Promise<string> {
3✔
16
  return get0(url, options, 0);
3✔
17
}
3✔
18

1✔
19
/** Implementation of HTTP GET method */
1✔
20
function get0(
5!
UNCOV
21
  url: string,
✔
UNCOV
22
  options: RequestOptions | undefined,
×
UNCOV
23
  redirectCount: number,
×
UNCOV
24
): Promise<string> {
×
UNCOV
25
  const client = url.startsWith("https") ? https : http;
×
UNCOV
26
  const parsedOptions = parseUrlAndOptions(url, options || {});
✔
UNCOV
27

×
UNCOV
28
  return new Promise((resolve, reject) => {
×
UNCOV
29
    let result = "";
×
UNCOV
30
    const req = client.get(parsedOptions, (res) => {
✔
UNCOV
31
      res.on("data", (chunk) => {
✔
UNCOV
32
        result += chunk;
×
UNCOV
33
      });
×
UNCOV
34
      res.on("end", () => {
✔
UNCOV
35
        if (
×
UNCOV
36
          res.statusCode &&
✔
UNCOV
37
          res.statusCode >= 300 &&
✔
UNCOV
38
          res.statusCode < 400 &&
×
UNCOV
39
          redirectCount < 3 // max redirect
✔
UNCOV
40
        ) {
✔
UNCOV
41
          const location = res.headers.location!;
×
UNCOV
42
          try {
×
UNCOV
43
            const redirectUrl = new URL(location, url).toString();
✔
UNCOV
44
            resolve(get0(redirectUrl, options, redirectCount + 1));
✔
UNCOV
45
          } catch (e) {
×
46
            reject(e);
×
UNCOV
47
          }
×
UNCOV
48
          return;
×
UNCOV
49
        }
×
UNCOV
50
        resolve(result);
✔
UNCOV
51
      });
×
UNCOV
52
    });
×
UNCOV
53
    req.on("error", (e) => {
×
54
      reject(e);
×
UNCOV
55
    });
×
UNCOV
56
    req.setTimeout(TIMEOUT, function handleRequestTimeout() {
✔
57
      if (req.destroy) {
×
58
        req.destroy();
×
UNCOV
59
      } else {
×
60
        req.abort();
×
UNCOV
61
      }
×
62
      reject(new Error(`Timeout of ${TIMEOUT}ms exceeded`));
✔
UNCOV
63
    });
×
UNCOV
64
  });
×
UNCOV
65
}
×
UNCOV
66

×
UNCOV
67
/** Parse URL and options */
×
68
function parseUrlAndOptions(urlStr: string, baseOptions: RequestOptions) {
5✔
69
  const url = new URL(urlStr);
1✔
70
  const hostname =
1✔
UNCOV
71
    typeof url.hostname === "string" && url.hostname.startsWith("[")
×
UNCOV
72
      ? url.hostname.slice(1, -1)
×
UNCOV
73
      : url.hostname;
×
74
  const options: RequestOptions = {
5✔
75
    agent: false,
5✔
76
    ...baseOptions,
5✔
77
    protocol: url.protocol,
5✔
78
    hostname,
5✔
79
    path: `${url.pathname || ""}${url.search || ""}`,
5!
80
  };
5✔
81
  if (url.port !== "") {
5!
82
    options.port = Number(url.port);
×
UNCOV
83
  }
×
UNCOV
84
  if (url.username || url.password) {
×
85
    options.auth = `${url.username}:${url.password}`;
×
UNCOV
86
  }
×
87

5✔
88
  const PROXY_ENV = [
5✔
89
    "https_proxy",
5✔
90
    "HTTPS_PROXY",
5✔
91
    "http_proxy",
5✔
92
    "HTTP_PROXY",
5✔
93
    "npm_config_https_proxy",
5✔
94
    "npm_config_http_proxy",
5!
UNCOV
95
  ];
×
UNCOV
96

×
97
  const proxyStr: string =
5✔
98
    // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore
5✔
99
    (options as any)?.proxy ||
5✔
100
    // eslint-disable-next-line no-process-env -- ignore
5✔
101
    PROXY_ENV.map((k) => process.env[k]).find((v) => v);
5!
UNCOV
102
  if (proxyStr) {
×
103
    const proxyUrl = new URL(proxyStr);
×
UNCOV
104

×
105
    options.agent = tunnel[
×
UNCOV
106
      `http${url.protocol === "https:" ? "s" : ""}OverHttp${
×
UNCOV
107
        proxyUrl.protocol === "https:" ? "s" : ""
×
UNCOV
108
      }`
×
UNCOV
109
    ]({
×
UNCOV
110
      proxy: {
×
UNCOV
111
        host: proxyUrl.hostname,
×
UNCOV
112
        port: Number(proxyUrl.port),
×
UNCOV
113
        proxyAuth:
×
UNCOV
114
          proxyUrl.username || proxyUrl.password
×
UNCOV
115
            ? `${proxyUrl.username}:${proxyUrl.password}`
✔
116
            : undefined,
114✔
117
      },
114✔
118
    });
114✔
119
  }
114✔
120
  return options;
114✔
121
}
5✔
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

© 2026 Coveralls, Inc