test: fix undefined password

If no password is given, '+ password' stringifies to 'undefined', which
generates a URL that has 'undefined' as the password instead of leaving
out the password.
This commit is contained in:
Ryan Graham 2016-08-04 17:48:26 -07:00
parent 0fcaa35f52
commit ebb6e68f0e
No known key found for this signature in database
GPG Key ID: F15A82CDEFD85858
1 changed files with 4 additions and 1 deletions

View File

@ -170,11 +170,14 @@ var query = function (sql, cb) {
function generateURL(config) {
var urlObj = {
protocol: 'mysql',
auth: config.username + ':' + config.password,
auth: config.username || '',
hostname: config.host,
pathname: config.database,
slashes: true
};
if (config.password) {
urlObj.auth += ':' + config.password;
}
var formatedUrl = url.format(urlObj);
return formatedUrl;
}