mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: only lookup localhost
for DNS lookups
This commit is contained in:
parent
eb7cd717ed
commit
1b025b4c84
@ -23,13 +23,15 @@ export class NodeWebSocketTransport implements ConnectionTransport {
|
||||
// TODO(jrandolf): Starting in Node 17, IPv6 is favoured over IPv4 due to a change
|
||||
// in a default option:
|
||||
// - https://github.com/nodejs/node/issues/40537,
|
||||
// Due to this, we parse and resolve the hostname manually with the previous
|
||||
// behavior according to:
|
||||
// Due to this, for Firefox, we must parse and resolve the `localhost` hostname
|
||||
// manually with the previous behavior according to:
|
||||
// - https://nodejs.org/api/dns.html#dnslookuphostname-options-callback
|
||||
// because of https://bugzilla.mozilla.org/show_bug.cgi?id=1769994.
|
||||
const url = new URL(urlString);
|
||||
if (url.hostname === 'localhost') {
|
||||
const { address } = await dns.lookup(url.hostname, { verbatim: false });
|
||||
url.hostname = address;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const ws = new NodeWebSocket(url, [], {
|
||||
|
Loading…
Reference in New Issue
Block a user