mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
http: trim off brackets from IPv6 addresses with string operations
This is simpler than using regular expressions. PR-URL: https://github.com/nodejs/node/pull/59420 Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
ebbdea29ac
commit
6c215fb746
@ -112,7 +112,9 @@ class ProxyConfig {
|
||||
const { host, hostname, port, protocol, username, password } = new URL(proxyUrl);
|
||||
this.href = proxyUrl; // Full URL of the proxy server.
|
||||
this.host = host; // Full host including port, e.g. 'localhost:8080'.
|
||||
this.hostname = hostname.replace(/^\[|\]$/g, ''); // Trim off the brackets from IPv6 addresses.
|
||||
// Trim off the brackets from IPv6 addresses. As it's parsed from a valid URL, an opening
|
||||
// "[" Must already have a matching "]" at the end.
|
||||
this.hostname = hostname[0] === '[' ? hostname.slice(1, -1) : hostname;
|
||||
this.port = port ? NumberParseInt(port, 10) : (protocol === 'https:' ? 443 : 80);
|
||||
this.protocol = protocol; // Protocol of the proxy server, e.g. 'http:' or 'https:'.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user