File tree 3 files changed +15
-1
lines changed
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 () {
749
749
options . method = this . method ;
750
750
options . port = url . port ;
751
751
options . path = path ;
752
- options . host = url . hostname ;
752
+ options . host = utils . normalizeHostname ( url . hostname ) ; // ex: [::1] -> ::1
753
753
options . ca = this . _ca ;
754
754
options . key = this . _key ;
755
755
options . pfx = this . _pfx ;
Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ exports.cleanHeader = (header, changesOrigin) => {
71
71
return header ;
72
72
} ;
73
73
74
+ exports . normalizeHostname = ( hostname ) => {
75
+ const [ , normalized ] = hostname . match ( / ^ \[ ( [ ^ \] ] + ) \] $ / ) || [ ] ;
76
+ return normalized || hostname ;
77
+ } ;
78
+
74
79
/**
75
80
* Check if `obj` is an object.
76
81
*
Original file line number Diff line number Diff line change @@ -134,6 +134,15 @@ describe('[node] request', () => {
134
134
} ) ;
135
135
} ) ;
136
136
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
+
137
146
describe ( '.buffer()' , ( ) => {
138
147
it ( 'should enable buffering' , ( done ) => {
139
148
request
You can’t perform that action at this time.
0 commit comments