@@ -112,7 +112,9 @@ class ProxyConfig {
|
112 | 112 | const { host, hostname, port, protocol, username, password } = new URL(proxyUrl); |
113 | 113 | this.href = proxyUrl; // Full URL of the proxy server. |
114 | 114 | this.host = host; // Full host including port, e.g. 'localhost:8080'. |
115 | | -this.hostname = hostname.replace(/^\[|\]$/g, ''); // Trim off the brackets from IPv6 addresses. |
| 115 | +// Trim off the brackets from IPv6 addresses. As it's parsed from a valid URL, an opening |
| 116 | +// "[" Must already have a matching "]" at the end. |
| 117 | +this.hostname = hostname[0] === '[' ? hostname.slice(1, -1) : hostname; |
116 | 118 | this.port = port ? NumberParseInt(port, 10) : (protocol === 'https:' ? 443 : 80); |
117 | 119 | this.protocol = protocol; // Protocol of the proxy server, e.g. 'http:' or 'https:'. |
118 | 120 | |
|