replace space by %20 in connection string before passing to url.parse
This commit is contained in:
parent
a24102c237
commit
7d773508fc
@ -16,6 +16,8 @@ var parse = function(str) {
|
||||
if(str.charAt(0) === '/') {
|
||||
return { host: str };
|
||||
}
|
||||
// url parse expects spaces encoded as %20
|
||||
str = str.replace(' ', '%20');
|
||||
var result = url.parse(str);
|
||||
var config = {};
|
||||
config.host = result.hostname;
|
||||
|
@ -39,6 +39,15 @@ test('initializing from a config string', function() {
|
||||
assert.equal(client.database, "databasename")
|
||||
})
|
||||
|
||||
test('uses the correct values from the config string with space in password', function() {
|
||||
var client = new Client("pg://brian:pass word@host1:333/databasename")
|
||||
assert.equal(client.user, 'brian')
|
||||
assert.equal(client.password, "pass word")
|
||||
assert.equal(client.host, "host1")
|
||||
assert.equal(client.port, 333)
|
||||
assert.equal(client.database, "databasename")
|
||||
})
|
||||
|
||||
test('when not including all values the defaults are used', function() {
|
||||
var client = new Client("pg://host1")
|
||||
assert.equal(client.user, process.env['PGUSER'] || process.env.USER)
|
||||
|
Loading…
Reference in New Issue
Block a user