feat(core): support proxy config for pupperteer (#10714)

* feat: support proxy config for pupperteer

* test: add puppeteer proxy detection

* fix: package.json

* test: fix regex
This commit is contained in:
DIYgod
2022-09-06 17:07:04 +01:00
committed by GitHub
parent 57b466908f
commit 9329a44c80
6 changed files with 55 additions and 4 deletions

View File

@@ -73,11 +73,17 @@ const requestWrapper = (url, options) => {
if (agent && new RegExp(config.proxy.url_regex).test(url)) {
let agentResult;
try {
agentResult = agent[(options.protocol || url.match(/(https?:)/)[1]).slice(0, -1)];
agentResult = agent[(options.protocol || url.match(/(^https?:)/)[1]).slice(0, -1)];
} catch (error) {
agentResult = null;
}
options.agent = agentResult;
try {
if (new URL(url).host !== new URL(config.proxyUri).host) {
options.agent = agentResult;
}
} catch (error) {
options.agent = agentResult;
}
if (config.proxy.auth) {
if (!options.headers) {