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

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

18 Jan 2026 06:54AM UTC coverage: 35.082% (-52.3%) from 87.363%
21107667783

Pull #452

github

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

177 of 507 branches covered (34.91%)

Branch coverage included in aggregate %.

8 of 20 new or added lines in 4 files covered. (40.0%)

518 existing lines in 13 files now uncovered.

338 of 961 relevant lines covered (35.17%)

9.52 hits per line

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

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

7
const TIMEOUT = 60000;
1✔
8

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

19
/** Implementation of HTTP GET method */
20
function get0(
1✔
21
  url: string,
22
  options: RequestOptions | undefined,
23
  redirectCount: number,
24
): Promise<string> {
UNCOV
25
  const client = url.startsWith("https") ? https : http;
×
UNCOV
26
  const parsedOptions = parseUrlAndOptions(url, options || {});
×
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;
×
33
      });
UNCOV
34
      res.on("end", () => {
×
UNCOV
35
        if (
×
36
          res.statusCode &&
×
37
          res.statusCode >= 300 &&
38
          res.statusCode < 400 &&
39
          redirectCount < 3 // max redirect
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));
×
45
          } catch (e) {
46
            reject(e);
×
47
          }
UNCOV
48
          return;
×
49
        }
UNCOV
50
        resolve(result);
×
51
      });
52
    });
UNCOV
53
    req.on("error", (e) => {
×
54
      reject(e);
×
55
    });
UNCOV
56
    req.setTimeout(TIMEOUT, function handleRequestTimeout() {
×
57
      if (req.destroy) {
×
58
        req.destroy();
×
59
      } else {
60
        req.abort();
×
61
      }
62
      reject(new Error(`Timeout of ${TIMEOUT}ms exceeded`));
×
63
    });
64
  });
65
}
66

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

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

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

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