summaryrefslogtreecommitdiff
path: root/lib/url.js
diff options
context:
space:
mode:
authorseebees <seebees@gmail.com>2011-10-14 17:13:16 -0700
committerkoichik <koichik@improvement.jp>2011-10-22 14:14:40 +0900
commit1ead20f27466438600be03af9cc92073e8f44c13 (patch)
tree8c551791d7e3f15952e1c3cabc36ad1bd69b7713 /lib/url.js
parent005d607aedf57eac046834060f3f6e8f24817407 (diff)
downloadnode-1ead20f27466438600be03af9cc92073e8f44c13.tar.gz
remove auth from host
Fixes #1626
Diffstat (limited to 'lib/url.js')
-rw-r--r--lib/url.js23
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/url.js b/lib/url.js
index e6915b42c..f6d863165 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -169,7 +169,6 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
// pull out port.
var p = parseHost(out.host);
- if (out.auth) out.host = out.auth + '@' + out.host;
var keys = Object.keys(p);
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
@@ -235,8 +234,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
}
out.hostname = newOut.join('.');
- out.host = ((out.auth) ? out.auth + '@' : '') +
- (out.hostname || '') +
+ out.host = (out.hostname || '') +
((out.port) ? ':' + out.port : '');
out.href += out.host;
}
@@ -314,20 +312,20 @@ function urlFormat(obj) {
// to clean up potentially wonky urls.
if (typeof(obj) === 'string') obj = urlParse(obj);
- var auth = obj.auth;
+ var auth = obj.auth || '';
if (auth) {
auth = auth.split('@').join('%40');
for (var i = 0, l = nonAuthChars.length; i < l; i++) {
var nAC = nonAuthChars[i];
auth = auth.split(nAC).join(encodeURIComponent(nAC));
}
+ auth += '@';
}
var protocol = obj.protocol || '',
- host = (obj.host !== undefined) ? obj.host :
+ host = (obj.host !== undefined) ? auth + obj.host :
obj.hostname !== undefined ? (
- (auth ? auth + '@' : '') +
- obj.hostname +
+ auth + obj.hostname +
(obj.port ? ':' + obj.port : '')
) :
false,
@@ -449,17 +447,14 @@ function urlResolveObject(source, relative) {
if (psychotic) {
delete source.hostname;
- delete source.auth;
delete source.port;
if (source.host) {
if (srcPath[0] === '') srcPath[0] = source.host;
else srcPath.unshift(source.host);
}
delete source.host;
-
if (relative.protocol) {
delete relative.hostname;
- delete relative.auth;
delete relative.port;
if (relative.host) {
if (relPath[0] === '') relPath[0] = relative.host;
@@ -501,7 +496,7 @@ function urlResolveObject(source, relative) {
source.host.split('@') : false;
if (authInHost) {
source.auth = authInHost.shift();
- source.hostname = authInHost.shift();
+ source.host = source.hostname = authInHost.shift();
}
}
source.search = relative.search;
@@ -580,8 +575,8 @@ function urlResolveObject(source, relative) {
var authInHost = source.host && source.host.indexOf('@') > 0 ?
source.host.split('@') : false;
if (authInHost) {
- relative.auth = authInHost.shift();
- source.hostname = authInHost.shift();
+ source.auth = authInHost.shift();
+ source.host = source.hostname = authInHost.shift();
}
}
@@ -597,7 +592,7 @@ function urlResolveObject(source, relative) {
source.path = (source.pathname ? source.pathname : '') +
(source.search ? source.search : '');
}
- source.auth = relative.auth;
+ source.auth = relative.auth || source.auth;
source.slashes = source.slashes || relative.slashes;
source.href = urlFormat(source);
return source;