Skip to content

Commit 76a159b

Browse files
NdpntMattiSG
andauthored
Simplify code
Co-authored-by: Matti Schneider <gh@mattischneider.fr>
1 parent d889a5a commit 76a159b

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/archivist/fetcher/fullDomFetcher.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ export async function launchHeadlessBrowser() {
107107

108108
proxyCredentials = extractProxyCredentials(httpProxy, httpsProxy);
109109

110-
options.args = [].concat(options.args, `--proxy-server=http=${httpProxyUrl.host};https=${httpsProxyUrl.host}`);
110+
options.args.push(`--proxy-server=http=${httpProxyUrl.host};https=${httpsProxyUrl.host}`);
111111
}
112112

113113
if (process.env.FETCHER_NO_SANDBOX) {
114-
options.args = [].concat(options.args, [ '--no-sandbox', '--disable-setuid-sandbox' ]);
114+
options.args.push('--no-sandbox');
115+
options.args.push('--disable-setuid-sandbox');
115116
}
116117

117118
browser = await puppeteer.launch(options);

src/archivist/fetcher/proxyUtils.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
export function resolveProxyConfiguration() {
2-
let httpProxy = null;
3-
let httpsProxy = null;
2+
const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY;
3+
const httpsProxy = process.env.https_proxy || process.env.HTTPS_PROXY || httpProxy;
44

5-
if (process.env.http_proxy) {
6-
httpProxy = process.env.http_proxy;
7-
} else if (process.env.HTTP_PROXY) {
8-
httpProxy = process.env.HTTP_PROXY;
9-
}
10-
11-
if (process.env.https_proxy) {
12-
httpsProxy = process.env.https_proxy;
13-
} else if (process.env.HTTPS_PROXY) {
14-
httpsProxy = process.env.HTTPS_PROXY;
15-
} else if (httpProxy) {
16-
httpsProxy = httpProxy;
17-
}
18-
19-
return { httpProxy, httpsProxy };
5+
return {
6+
httpProxy,
7+
httpsProxy
8+
};
209
}
2110

2211
export function extractProxyCredentials(httpProxy, httpsProxy) {

0 commit comments

Comments
 (0)