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) {
|
function generateURL(config) {
|
||||||
var urlObj = {
|
var urlObj = {
|
||||||
protocol: 'mysql',
|
protocol: 'mysql',
|
||||||
auth: config.username + ':' + config.password,
|
auth: config.username || '',
|
||||||
hostname: config.host,
|
hostname: config.host,
|
||||||
pathname: config.database,
|
pathname: config.database,
|
||||||
slashes: true
|
slashes: true
|
||||||
};
|
};
|
||||||
|
if (config.password) {
|
||||||
|
urlObj.auth += ':' + config.password;
|
||||||
|
}
|
||||||
var formatedUrl = url.format(urlObj);
|
var formatedUrl = url.format(urlObj);
|
||||||
return formatedUrl;
|
return formatedUrl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue