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:
parent
0fcaa35f52
commit
ebb6e68f0e
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue