Skip to content

Commit

Permalink
[minor] Added missing JSDoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Sep 12, 2014
1 parent 3ab6e95 commit 73e8a4c
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions lib/http-proxy/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,36 @@ common.setupSocket = function(socket) {
return socket;
};

/**
* Get the port number from the host. Or guess it based on the connection type.
*
* @param {Request} req Incoming HTTP request.
*
* @return {String} The port number.
*
* @api private
*/
common.getPort = function(req) {
var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : "";
var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : '';

return res ?
res[1] :
req.connection.pair ? '443' : '80' ;
req.connection.pair ? '443' : '80';
};

// OS-agnostic join (doesn't break on URLs like path.join does on Windows)
/**
* OS-agnostic join (doesn't break on URLs like path.join does on Windows)>
*
* @return {String} The generated path.
*
* @api private
*/

common.urlJoin = function() {
var args = Array.prototype.slice.call(arguments);
// Join all strings, but remove empty strings so we don't get extra slashes from
// Join all strings, but remove empty strings so we don't get extra slashes from
// joining e.g. ['', 'am']
return args.filter(function(a) { return !!a; }).join('/').replace(/\/+/g, '/');
return args.filter(function filter(a) {
return !!a;
}).join('/').replace(/\/+/g, '/');
};

0 comments on commit 73e8a4c

Please sign in to comment.