Skip to content

Commit c5c081e

Browse files
committed
fix: explicitly enumerate protocols
1 parent d8795a8 commit c5c081e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/configproxy.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,14 @@ export class ConfigurableProxy extends EventEmitter {
397397
proxyOptions.secure = false;
398398
proxyOptions.target.socketPath = decodeURIComponent(target.host);
399399
proxyOptions.target.pathname = (target.pathname ? target.pathname + "/" : "") + reqUrl;
400+
} else if (target.protocol.startsWith("https")) {
401+
proxyOptions.secure = true;
402+
proxyOptions.agent = this.httpsAgent;
403+
} else if (target.protocol.startsWith("http")) {
404+
proxyOptions.secure = false;
405+
proxyOptions.agent = this.httpAgent;
400406
} else {
401-
proxyOptions.secure = target.protocol.slice(-2) === "s:";
402-
403-
if (proxyOptions.secure) {
404-
proxyOptions.agent = this.httpsAgent;
405-
} else {
406-
proxyOptions.agent = this.httpAgent;
407-
}
407+
throw new Error(`Unexpected protocol ${target.protocol}`);
408408
}
409409

410410
if (proxyOptions.secure && this.options.clientSsl) {

0 commit comments

Comments
 (0)