Skip to content

Commit

Permalink
make it possible to use ":" in passwords in a DSN (#334)
Browse files Browse the repository at this point in the history
* make it possible to use ":" in passwords in a DSN

* CS

* more hacking to work around lint rules :-/
  • Loading branch information
iamjochem authored and sushantdhiman committed Aug 6, 2016
1 parent d526a8e commit 99878bc
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions lib/tasks/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,29 +302,30 @@ function getSequelizeInstance () {
options[key] = value;
}

if (key === 'use_env_variable') {
if (process.env[value]) {
var dbUrl = url.parse(process.env[value]);
var protocol = dbUrl.protocol.split(':')[0];
if (key === 'use_env_variable' && process.env[value]) {
var dbUrl = url.parse(process.env[value]);
var protocol = dbUrl.protocol.split(':')[0];

config.database = dbUrl.pathname.substring(1);
config.database = dbUrl.pathname.substring(1);

if (protocol === 'sqlite') {
options.storage = dbUrl.pathname;
} else if (dbUrl.auth) {
var auth = dbUrl.auth.split(':');
if (protocol === 'sqlite') {
options.storage = dbUrl.pathname;
} else if (dbUrl.auth) {
var authParts = dbUrl.auth.split(':');

config.username = auth[0];
config.password = auth[1];
}
config.username = authParts[0];

options = _.assign(options, {
host: dbUrl.hostname,
port: dbUrl.port,
dialect: protocol,
protocol: protocol
});
if (authParts.length > 1) {
config.password = authParts.slice(1).join(':');
}
}

options = _.assign(options, {
host: dbUrl.hostname,
port: dbUrl.port,
dialect: protocol,
protocol: protocol
});
}

if (key === 'dialectOptions') {
Expand Down

0 comments on commit 99878bc

Please sign in to comment.