Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for passing connection parameters as an object #159

Merged
merged 3 commits into from
Jun 21, 2015
Merged

add support for passing connection parameters as an object #159

merged 3 commits into from
Jun 21, 2015

Conversation

ben-page
Copy link
Contributor

The built in url.parse() does not properly handle encoded variables in the username or password. Consequently, some username and/or passwords can not be based to amqplib as a URL. For reference, see: nodejs/node-v0.x-archive#25353

So, I updated connect() to support passing connection parameters as an object:

var url = {
    protocol: 'amqp', //amqp or amqps
    username: 'someone',
    password: 'secret',
    hostname: '127.0.0.1',
    port: 5672,
    vhost: 'name'
}
connect([url, [socketOptions]], function(err, conn) {...})

sockopts.host = url.hostname;
sockopts.port = url.port || ((protocol === 'amqp:') ? 5672 : 5671);
if (!url.username) {
url.username = 'guest';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If url is mutated, perhaps it's best to clone it. This way the user won't be surprised if the value is used elsewhere.

@ben-page
Copy link
Contributor Author

@squaremo I agree with your comment. I updated accordingly.

@squaremo squaremo merged commit 7d9a25c into amqp-node:master Jun 21, 2015
@squaremo
Copy link
Collaborator

Thank you! Sorry I took a while to get to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants