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

realm / realm-js / 6051596871

01 Sep 2023 04:13PM CUT coverage: 85.294%. First build
6051596871

Pull #6100

github

GitHub
Merge 2fc9db884 into 7b55e16d3
Pull Request #6100:

885 of 1100 branches covered (0.0%)

Branch coverage included in aggregate %.

2305 of 2640 relevant lines covered (87.31%)

800.74 hits per line

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

26.32
/packages/realm/src/platform/node/sync-proxy-config.ts
1
////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2023 Realm Inc.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
//
17
////////////////////////////////////////////////////////////////////////////
18

19
import process from "node:process";
20
import { URL } from "node:url";
21

22
import { ProxyType } from "realm/binding";
23
import { inject } from "../sync-proxy-config";
24

25
inject({
1✔
26
  create() {
27
    for (const envVar of ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"]) {
1,515✔
28
      const proxyUrlAsString = process.env[envVar];
6,060✔
29
      if (proxyUrlAsString) {
6,060!
30
        let type: ProxyType;
31
        const proxyUrl = new URL(proxyUrlAsString);
×
32
        const protocol = proxyUrl.protocol;
×
33
        if (protocol === "http:") {
×
34
          type = ProxyType.Http;
×
35
        } else if (protocol === "https:") {
×
36
          type = ProxyType.Https;
×
37
        } else {
38
          throw new Error(`Expected either 'http' or 'https' as protocol for ${envVar} (got ${protocol})`);
×
39
        }
40

41
        const config = {
×
42
          address: proxyUrl.hostname,
43
          type,
44
          port: parseInt(proxyUrl.port, 10),
45
        };
46
        return config;
×
47
      }
48
    }
49

50
    // no environment variable found, and we skip the proxy configuration
51
    return undefined;
1,515✔
52
  },
53
});
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