File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -749,7 +749,7 @@ Request.prototype.request = function () {
749749 options . method = this . method ;
750750 options . port = url . port ;
751751 options . path = path ;
752- options . host = url . hostname ;
752+ options . host = utils . normalizeHostname ( url . hostname ) ; // ex: [::1] -> ::1
753753 options . ca = this . _ca ;
754754 options . key = this . _key ;
755755 options . pfx = this . _pfx ;
Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ exports.cleanHeader = (header, changesOrigin) => {
7171 return header ;
7272} ;
7373
74+ exports . normalizeHostname = ( hostname ) => {
75+ const [ , normalized ] = hostname . match ( / ^ \[ ( [ ^ \] ] + ) \] $ / ) || [ ] ;
76+ return normalized || hostname ;
77+ } ;
78+
7479/**
7580 * Check if `obj` is an object.
7681 *
Original file line number Diff line number Diff line change @@ -134,6 +134,15 @@ describe('[node] request', () => {
134134 } ) ;
135135 } ) ;
136136
137+ describe ( 'ipv6 address' , ( ) => {
138+ it ( 'should successfully query an ipv6 address' , ( done ) => {
139+ request . get ( `http://[::]/url?a=(b%29` ) . end ( ( error , res ) => {
140+ assert . equal ( '/url?a=(b%29' , res . text ) ;
141+ done ( ) ;
142+ } ) ;
143+ } ) ;
144+ } ) ;
145+
137146 describe ( '.buffer()' , ( ) => {
138147 it ( 'should enable buffering' , ( done ) => {
139148 request
You can’t perform that action at this time.
0 commit comments