@@ -216,7 +216,7 @@ describe('lib/http-proxy/common.js', function () {
216
216
//
217
217
// This is the proper failing test case for the common.join problem
218
218
//
219
- it ( 'should correctly format the a toProxy URL' , function ( ) {
219
+ it ( 'should correctly format the toProxy URL' , function ( ) {
220
220
var outgoing = { } ;
221
221
var google = 'https://google.com'
222
222
common . setupOutgoing ( outgoing , {
@@ -225,7 +225,33 @@ describe('lib/http-proxy/common.js', function () {
225
225
} , { url : google } ) ;
226
226
227
227
expect ( outgoing . path ) . to . eql ( '/' + google ) ;
228
- } )
228
+ } ) ;
229
+
230
+ describe ( 'when using changeOrigin' , function ( ) {
231
+ it ( 'should correctly set the port to the host when it is a non-standard port using url.parse' , function ( ) {
232
+ var outgoing = { } ;
233
+ var myEndpoint = 'https://myCouch.com:6984' ;
234
+ common . setupOutgoing ( outgoing , {
235
+ target : url . parse ( myEndpoint ) ,
236
+ changeOrigin : true
237
+ } , { url : '/' } ) ;
238
+
239
+ expect ( outgoing . headers . host ) . to . eql ( 'mycouch.com:6984' ) ;
240
+ } ) ;
241
+ it ( 'should correctly set the port to the host when it is a non-standard port when setting host and port manually (which ignores port)' , function ( ) {
242
+ var outgoing = { } ;
243
+ common . setupOutgoing ( outgoing , {
244
+ target : {
245
+ protocol : 'https:' ,
246
+ host : 'mycouch.com' ,
247
+ port : 6984
248
+ } ,
249
+ changeOrigin : true
250
+ } , { url : '/' } ) ;
251
+ expect ( outgoing . headers . host ) . to . eql ( 'mycouch.com:6984' ) ;
252
+ } )
253
+ } ) ;
254
+
229
255
} ) ;
230
256
231
257
describe ( '#setupSocket' , function ( ) {
0 commit comments