Skip to content

Commit 0f925f6

Browse files
committed
Merge pull request brianc#259 from francoisp/master
here's the change and the test
2 parents a24102c + 7d77350 commit 0f925f6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/connection-parameters.js

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ var parse = function(str) {
1616
if(str.charAt(0) === '/') {
1717
return { host: str };
1818
}
19+
// url parse expects spaces encoded as %20
20+
str = str.replace(' ', '%20');
1921
var result = url.parse(str);
2022
var config = {};
2123
config.host = result.hostname;

test/unit/client/configuration-tests.js

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ test('initializing from a config string', function() {
3939
assert.equal(client.database, "databasename")
4040
})
4141

42+
test('uses the correct values from the config string with space in password', function() {
43+
var client = new Client("pg://brian:pass word@host1:333/databasename")
44+
assert.equal(client.user, 'brian')
45+
assert.equal(client.password, "pass word")
46+
assert.equal(client.host, "host1")
47+
assert.equal(client.port, 333)
48+
assert.equal(client.database, "databasename")
49+
})
50+
4251
test('when not including all values the defaults are used', function() {
4352
var client = new Client("pg://host1")
4453
assert.equal(client.user, process.env['PGUSER'] || process.env.USER)

0 commit comments

Comments
 (0)