mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Add supporting password with colon
This commit is contained in:
parent
245abd6daf
commit
fbdd033d6c
2
index.js
2
index.js
@ -47,7 +47,7 @@ function parse(str) {
|
||||
|
||||
var auth = (result.auth || ':').split(':');
|
||||
config.user = auth[0];
|
||||
config.password = auth[1];
|
||||
config.password = auth.splice(1).join(':');
|
||||
|
||||
var ssl = result.query.ssl;
|
||||
if (ssl === 'true' || ssl === '1') {
|
||||
|
||||
@ -69,6 +69,20 @@ test('password contains < and/or > characters', function(t){
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('password contains colons', function(t){
|
||||
var sourceConfig = {
|
||||
user:'brian',
|
||||
password: 'hello:pass:world',
|
||||
port: 5432,
|
||||
host: 'localhost',
|
||||
database: 'postgres'
|
||||
};
|
||||
var connectionString = 'postgres://' + sourceConfig.user + ':' + sourceConfig.password + '@' + sourceConfig.host + ':' + sourceConfig.port + '/' + sourceConfig.database;
|
||||
var subject = parse(connectionString);
|
||||
t.equal(subject.password, sourceConfig.password);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('username or password contains weird characters', function(t){
|
||||
var strang = 'pg://my f%irst name:is&%awesome!@localhost:9000';
|
||||
var subject = parse(strang);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user