mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Merge branch 'pull/326'
Conflicts: lib/connection-parameters.js test/unit/connection-parameters/creation-tests.js
This commit is contained in:
commit
bf0c4bfaa9
@ -27,7 +27,9 @@ var parse = function(str) {
|
||||
return { host: config[0], database: config[1] };
|
||||
}
|
||||
// url parse expects spaces encoded as %20
|
||||
if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str)) str = encodeURI(str);
|
||||
if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str)) {
|
||||
str = encodeURI(str).replace(/\%25(\d\d)/g, "%$1");
|
||||
}
|
||||
var result = url.parse(str, true);
|
||||
config = {};
|
||||
|
||||
|
||||
@ -184,17 +184,26 @@ test('libpq connection string building', function() {
|
||||
assert.equal(subject.password, sourceConfig.password);
|
||||
});
|
||||
|
||||
test('password contains weird characters', function() {
|
||||
test('username or password contains weird characters', function() {
|
||||
var defaults = require('../../../lib/defaults');
|
||||
defaults.ssl = true;
|
||||
var strang = 'postgres://my first name:is&%awesome!@localhost:9000';
|
||||
var strang = 'pg://my f%irst name:is&%awesome!@localhost:9000';
|
||||
var subject = new ConnectionParameters(strang);
|
||||
assert.equal(subject.user, 'my first name');
|
||||
assert.equal(subject.user, 'my f%irst name');
|
||||
assert.equal(subject.password, 'is&%awesome!');
|
||||
assert.equal(subject.host, 'localhost');
|
||||
assert.equal(subject.ssl, true);
|
||||
});
|
||||
|
||||
test("url is properly encoded", function() {
|
||||
var encoded = "pg://bi%25na%25%25ry%20:s%40f%23@localhost/%20u%2520rl";
|
||||
var subject = new ConnectionParameters(encoded);
|
||||
assert.equal(subject.user, "bi%na%%ry ");
|
||||
assert.equal(subject.password, "s@f#");
|
||||
assert.equal(subject.host, 'localhost');
|
||||
assert.equal(subject.database, " u%20rl");
|
||||
});
|
||||
|
||||
test('ssl is set on client', function() {
|
||||
var Client = require('../../../lib/client')
|
||||
var defaults = require('../../../lib/defaults');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user