url: moar simplifications

This commit is contained in:
Guillermo Rauch
2012-12-16 21:14:44 -03:00
parent 0c6b0b4111
commit f5d6ff56d7

View File

@@ -22,9 +22,7 @@ module.exports = parse;
function parse(uri){
var obj = uri;
if (null == url) {
url = location.protocol + '//' + location.hostname;
}
if (null == url) url = location.protocol + '//' + location.hostname;
if ('string' == typeof uri) {
if ('/' == uri.charAt(0)) {
@@ -48,9 +46,6 @@ function parse(uri){
obj = url.parse(uri);
}
// in absence of `protocol`
if (!obj.protocol) obj.protocol = obj.secure ? 'https:' : 'http:';
// make sure we treat `localhost:80` and `localhost` equally
if ((/(http|ws):/.test(obj.protocol) && 80 == obj.port) ||
(/(http|ws)s:/.test(obj.protocol) && 443 == obj.port)) {