[minor] Added missing JSDoc comments

This commit is contained in:
Arnout Kazemier 2014-09-12 19:21:12 +02:00
parent 3ab6e9591e
commit 73e8a4cdd5

View File

@ -102,17 +102,36 @@ common.setupSocket = function(socket) {
return 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) { 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 ? return res ?
res[1] : 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() { common.urlJoin = function() {
var args = Array.prototype.slice.call(arguments); 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'] // 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, '/');
}; };