Skip to content

Commit

Permalink
Decode connection url
Browse files Browse the repository at this point in the history
  • Loading branch information
cressie176 committed Mar 8, 2024
1 parent 42bf7f0 commit 41865c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/config/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
17 changes: 17 additions & 0 deletions test/config.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit 41865c2

Please sign in to comment.