stream-http
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -14,3 +14,8 @@ var ClientRequest = require('./lib/request') | ||
var protocol = opts.protocol || '' | ||
// Normally, the page is loaded from http or https, so not specifying a protocol | ||
// will result in a (valid) protocol-relative url. However, this won't work if | ||
// the protocol is something else, like 'file:' | ||
var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : '' | ||
var protocol = opts.protocol || defaultProtocol | ||
var host = opts.hostname || opts.host | ||
@@ -17,0 +22,0 @@ var port = opts.port |
{ | ||
"name": "stream-http", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Streaming http in the browser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -67,2 +67,21 @@ // These tests are teken from http-browserify to ensure compatibility with | ||
test('Test page with \'file:\' protocol', function (t) { | ||
var params = { | ||
hostname: 'localhost', | ||
port: 3000, | ||
path: '/bar' | ||
} | ||
var fileLocation = 'file:///home/me/stuff/index.html' | ||
var normalLocation = global.location | ||
global.location = url.parse(fileLocation) // Temporarily change the location | ||
var request = http.get(params, noop) | ||
global.location = normalLocation // Reset the location | ||
var resolved = url.resolve(fileLocation, request._opts.url) | ||
t.equal(resolved, 'http://localhost:3000/bar', 'Url should be correct') | ||
t.end() | ||
}) | ||
test('Test string as parameters', function(t) { | ||
@@ -69,0 +88,0 @@ var testUrl = '/api/foo' |
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
80260
1237