Comparing version 2.2.0 to 2.2.1
@@ -67,2 +67,11 @@ 'use strict' | ||
function getServerName (client, host) { | ||
return ( | ||
util.getServerName(host) || | ||
(client[kTLSOpts] && client[kTLSOpts].servername) || | ||
util.getServerName(client[kUrl].host || client[kUrl].hostname) || | ||
null | ||
) | ||
} | ||
class Client extends EventEmitter { | ||
@@ -155,5 +164,5 @@ constructor (url, { | ||
this[kDestroyed] = false | ||
this[kTLSServerName] = (tls && tls.servername) || null | ||
this[kTLSOpts] = tls | ||
this[kTLSServerName] = getServerName(this) | ||
this[kHost] = null | ||
this[kTLSOpts] = tls | ||
this[kRetryDelay] = 0 | ||
@@ -922,7 +931,3 @@ this[kRetryTimeout] = null | ||
const servername = ( | ||
request.host && | ||
!/^\[/.test(request.host) && | ||
!net.isIP(request.host) | ||
) ? request.host : (client[kTLSOpts] && client[kTLSOpts].servername) | ||
const servername = getServerName(client, request.host) | ||
@@ -929,0 +934,0 @@ if (client[kTLSServerName] !== servername) { |
@@ -7,2 +7,3 @@ 'use strict' | ||
const util = require('util') | ||
const net = require('net') | ||
@@ -15,2 +16,23 @@ function nop () {} | ||
function getServerName (host) { | ||
if (!host) { | ||
return null | ||
} | ||
let servername = host | ||
if (servername.startsWith('[')) { | ||
const idx = servername.indexOf(']') | ||
servername = idx === -1 ? servername : servername.substr(1, idx - 1) | ||
} else { | ||
servername = servername.split(':', 1)[0] | ||
} | ||
if (net.isIP(servername)) { | ||
servername = null | ||
} | ||
return servername | ||
} | ||
function bodyLength (body) { | ||
@@ -95,2 +117,3 @@ if (body && typeof body.on === 'function') { | ||
nop, | ||
getServerName, | ||
errnoException, | ||
@@ -97,0 +120,0 @@ isStream, |
{ | ||
"name": "undici", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
385808
12333
57