diff --git a/lib/config/configure.js b/lib/config/configure.js index 5386a7e..3e4b720 100644 --- a/lib/config/configure.js +++ b/lib/config/configure.js @@ -91,7 +91,7 @@ module.exports = _.curry((rascalConfig, next) => { } = new URL(connectionString); const options = Array.from(searchParams).reduce((attributes, entry) => ({ ...attributes, [entry[0]]: entry[1] }), {}); return { - protocol, hostname, port, user, password, vhost, options, + protocol, hostname: decodeURIComponent(hostname), port, user: decodeURIComponent(user), password: decodeURIComponent(password), vhost: decodeURIComponent(vhost), options, }; } diff --git a/test/config.tests.js b/test/config.tests.js index 4ec4bec..ad7808e 100644 --- a/test/config.tests.js +++ b/test/config.tests.js @@ -80,6 +80,23 @@ describe('Configuration', () => { ); }); + it('should support encoded urls', () => { + // See https://www.rabbitmq.com/docs/uri-spec#appendix-a-examples + configure( + { + vhosts: { + v1: { + connection: 'amqp://encoded%23user:encoded%23password@ho%61stname:9000/v%2fhost?heartbeat=10&channelMax=100', + }, + }, + }, + (err, config) => { + assert.ifError(err); + assert.strictEqual(config.vhosts.v1.connections[0].url, 'amqp://encoded%23user:encoded%23password@hoastname:9000/v/host?heartbeat=10&channelMax=100'); + }, + ); + }); + it('should report invalid urls', () => { configure( {