Comparing version 0.12.2 to 0.12.3
@@ -46,16 +46,8 @@ var RequestOverrider = require('./request_overrider'), | ||
options.proto = options.proto || 'http'; | ||
options.port = options.port || ((options.proto === 'http') ? 80 : 443); | ||
options.hostname = options.hostname || options.host.split(':')[0]; | ||
options.host = options.hostname + ':' + options.port; | ||
basePath = options.proto + '://' + options.host; | ||
if (!options.host) { | ||
options.host = options.hostname; | ||
} | ||
basePath = options.proto + '://' + options.host; | ||
if ( | ||
options.port && options.host.indexOf(':') < 0 && | ||
(options.port !== 80 || options.proto !== 'http') && | ||
(options.port !== 443 || options.proto !== 'https') | ||
) { | ||
basePath += ":" + options.port; | ||
} | ||
return allInterceptors[basePath] || []; | ||
@@ -62,0 +54,0 @@ } |
@@ -65,4 +65,4 @@ var IncomingMessage = require('http').IncomingMessage; | ||
if (options.host && +options.port !== 80) { | ||
hostHeader += ':' + options.port; | ||
if (options.port === 80 || options.port === 443) { | ||
hostHeader = hostHeader.split(':')[0]; | ||
} | ||
@@ -69,0 +69,0 @@ |
@@ -6,2 +6,3 @@ var path = require('path') | ||
, assert = require('assert') | ||
, url = require('url'); | ||
@@ -21,3 +22,7 @@ var noop = function() {}; | ||
logger = noop, | ||
scopeOptions = options || {}; | ||
scopeOptions = options || {}, | ||
urlParts = url.parse(basePath), | ||
port = urlParts.port || ((urlParts.protocol === 'http:') ? 80 : 443); | ||
basePath = urlParts.protocol + '//' + urlParts.hostname + ':' + port; | ||
@@ -24,0 +29,0 @@ function add(key, interceptor) { |
{ "name" : "nock" | ||
, "description" : "HTTP Server mocking for Node.js" | ||
, "tags" : ["Mock", "HTTP", "testing", "isolation"] | ||
, "version" : "0.12.2" | ||
, "version" : "0.12.3" | ||
, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com>" | ||
@@ -23,2 +23,3 @@ , "contributors" : | ||
, {"name": "Attila Incze"} | ||
, {"name": "Mac Angell"} | ||
] | ||
@@ -25,0 +26,0 @@ , "repository" : |
@@ -116,3 +116,3 @@ # Nock [](http://travis-ci.org/flatiron/nock) | ||
If you use HTTPS and port 80 or HTTPS and port 443, don't specify the port in the scope. Otherwise, you should specify the port like this: | ||
You are able to specify a non-standard port like this: | ||
@@ -119,0 +119,0 @@ var scope = nock('http://my.server.com:8081') |
@@ -1484,1 +1484,16 @@ var nock = require('../.') | ||
}); | ||
tap.test('explicitly specifiying port 80 works', function(t) { | ||
var scope = nock('http://abc.portyyyy.com:80') | ||
.get('/pathhh') | ||
.reply(200, "Welcome, username"); | ||
http.request({ | ||
hostname: 'abc.portyyyy.com', | ||
port: 80, | ||
path: '/pathhh' | ||
}, function(res) { | ||
scope.done(); | ||
t.end(); | ||
}).end(); | ||
}); |
65927
1911