[Pkg-javascript-commits] [node-stream-http] 84/208: Fix IPv6 addresses in requests
Bastien Roucariès
rouca at moszumanska.debian.org
Sun Aug 13 13:39:31 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stream-http.
commit bef2b95708e093467e76137b8a18b55f6fe4d682
Author: John Hiesey <john at hiesey.com>
Date: Wed Sep 9 20:22:18 2015 -0700
Fix IPv6 addresses in requests
Fixes #18
---
lib/request.js | 3 ++-
test/node/http-browserify.js | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/request.js b/lib/request.js
index 81e6dbc..cb7d012 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -31,7 +31,8 @@ var ClientRequest = module.exports = function (opts) {
stream.Writable.call(self)
self._opts = opts
- self._url = opts.protocol + '//' + opts.hostname + ':' + opts.port + opts.path
+ var hostname = opts.hostname.indexOf(':') === -1 ? opts.hostname : '[' + opts.hostname + ']'
+ self._url = opts.protocol + '//' + hostname + ':' + opts.port + opts.path
self._body = []
self._headers = {}
if (opts.auth)
diff --git a/test/node/http-browserify.js b/test/node/http-browserify.js
index 81f6ebd..38fbe2f 100644
--- a/test/node/http-browserify.js
+++ b/test/node/http-browserify.js
@@ -90,6 +90,14 @@ test('Test withCredentials param', function(t) {
t.end()
})
+test('Test ipv6 address', function(t) {
+ var url = 'http://[::1]:80/foo'
+ var request = http.get(url, noop)
+
+ t.equal( request._url, 'http://[::1]:80/foo', 'Url should be correct')
+ t.end()
+})
+
test('Cleanup', function (t) {
delete global.window
delete require.cache[moduleName]
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-http.git
More information about the Pkg-javascript-commits
mailing list