From ebb6e68f0e35cac068d07651b686540e8a3c0842 Mon Sep 17 00:00:00 2001 From: Ryan Graham Date: Thu, 4 Aug 2016 17:48:26 -0700 Subject: [PATCH] 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. --- test/connection.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/connection.test.js b/test/connection.test.js index 9dcda97..737250f 100644 --- a/test/connection.test.js +++ b/test/connection.test.js @@ -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; }