{"action":"created","comment":{"url":"https://api.github.com/repos/squaremo/amqp.node/pulls/comments/31083312","id":31083312,"diff_hunk":"@@ -107,12 +102,26 @@ function connect(url, socketOptions, openCallback) {\n   var keepAliveDelay = sockopts.keepAliveDelay || 0;\n \n   var extraClientProperties = sockopts.clientProperties || {};\n-  var credentials = sockopts.credentials || credentialsFromUrl(parts);\n+  \n+  var protocol, fields;\n+  if (typeof url === 'object') {\n+\tprotocol = (url.protocol || 'amqp') + ':';\n+\tsockopts.host = url.hostname;\n+\tsockopts.port = url.port || ((protocol === 'amqp:') ? 5672 : 5671);\n+    if (!url.username) {\n+      url.username = 'guest';","path":"lib/connect.js","position":61,"original_position":61,"commit_id":"8b08adaa5404e29264f59b2cd314bc92a53f515f","original_commit_id":"8b08adaa5404e29264f59b2cd314bc92a53f515f","user":{"login":"squaremo","id":62033,"avatar_url":"https://avatars.githubusercontent.com/u/62033?v=3","gravatar_id":"","url":"https://api.github.com/users/squaremo","html_url":"https://github.com/squaremo","followers_url":"https://api.github.com/users/squaremo/followers","following_url":"https://api.github.com/users/squaremo/following{/other_user}","gists_url":"https://api.github.com/users/squaremo/gists{/gist_id}","starred_url":"https://api.github.com/users/squaremo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squaremo/subscriptions","organizations_url":"https://api.github.com/users/squaremo/orgs","repos_url":"https://api.github.com/users/squaremo/repos","events_url":"https://api.github.com/users/squaremo/events{/privacy}","received_events_url":"https://api.github.com/users/squaremo/received_events","type":"User","site_admin":false},"body":"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.","created_at":"2015-05-26T21:47:07Z","updated_at":"2015-05-26T21:47:07Z","html_url":"https://github.com/squaremo/amqp.node/pull/159#discussion_r31083312","pull_request_url":"https://api.github.com/repos/squaremo/amqp.node/pulls/159","_links":{"self":{"href":"https://api.github.com/repos/squaremo/amqp.node/pulls/comments/31083312"},"html":{"href":"https://github.com/squaremo/amqp.node/pull/159#discussion_r31083312"},"pull_request":{"href":"https://api.github.com/repos/squaremo/amqp.node/pulls/159"}}},"pull_request":{"url":"https://api.github.com/repos/squaremo/amqp.node/pulls/159","id":36241173,"html_url":"https://github.com/squaremo/amqp.node/pull/159","diff_url":"https://github.com/squaremo/amqp.node/pull/159.diff","patch_url":"https://github.com/squaremo/amqp.node/pull/159.patch","issue_url":"https://api.github.com/repos/squaremo/amqp.node/issues/159","number":159,"state":"open","locked":false,"title":"add support for passing connection parameters as an object","user":{"login":"ben-page","id":744035,"avatar_url":"https://avatars.githubusercontent.com/u/744035?v=3","gravatar_id":"","url":"https://api.github.com/users/ben-page","html_url":"https://github.com/ben-page","followers_url":"https://api.github.com/users/ben-page/followers","following_url":"https://api.github.com/users/ben-page/following{/other_user}","gists_url":"https://api.github.com/users/ben-page/gists{/gist_id}","starred_url":"https://api.github.com/users/ben-page/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben-page/subscriptions","organizations_url":"https://api.github.com/users/ben-page/orgs","repos_url":"https://api.github.com/users/ben-page/repos","events_url":"https://api.github.com/users/ben-page/events{/privacy}","received_events_url":"https://api.github.com/users/ben-page/received_events","type":"User","site_admin":false},"body":"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: https://github.com/joyent/node/issues/25353\r\n\r\nSo, I updated connect() to support passing connection parameters as an object:\r\n```javascript\r\nvar url = {\r\n    protocol: 'amqp', //amqp or amqps\r\n    username: 'someone',\r\n    password: 'secret',\r\n    hostname: '127.0.0.1',\r\n    port: 5672,\r\n    vhost: 'name'\r\n}\r\nconnect([url, [socketOptions]], function(err, conn) {...})\r\n```\r\n\r\n","created_at":"2015-05-26T20:18:11Z","updated_at":"2015-05-26T21:47:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12985f84120581891c39c473de8ca0a62b0a679b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/squaremo/amqp.node/pulls/159/commits","review_comments_url":"https://api.github.com/repos/squaremo/amqp.node/pulls/159/comments","review_comment_url":"https://api.github.com/repos/squaremo/amqp.node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/squaremo/amqp.node/issues/159/comments","statuses_url":"https://api.github.com/repos/squaremo/amqp.node/statuses/8b08adaa5404e29264f59b2cd314bc92a53f515f","head":{"label":"ben-page:master","ref":"master","sha":"8b08adaa5404e29264f59b2cd314bc92a53f515f","user":{"login":"ben-page","id":744035,"avatar_url":"https://avatars.githubusercontent.com/u/744035?v=3","gravatar_id":"","url":"https://api.github.com/users/ben-page","html_url":"https://github.com/ben-page","followers_url":"https://api.github.com/users/ben-page/followers","following_url":"https://api.github.com/users/ben-page/following{/other_user}","gists_url":"https://api.github.com/users/ben-page/gists{/gist_id}","starred_url":"https://api.github.com/users/ben-page/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben-page/subscriptions","organizations_url":"https://api.github.com/users/ben-page/orgs","repos_url":"https://api.github.com/users/ben-page/repos","events_url":"https://api.github.com/users/ben-page/events{/privacy}","received_events_url":"https://api.github.com/users/ben-page/received_events","type":"User","site_admin":false},"repo":{"id":36319420,"name":"amqp.node","full_name":"ben-page/amqp.node","owner":{"login":"ben-page","id":744035,"avatar_url":"https://avatars.githubusercontent.com/u/744035?v=3","gravatar_id":"","url":"https://api.github.com/users/ben-page","html_url":"https://github.com/ben-page","followers_url":"https://api.github.com/users/ben-page/followers","following_url":"https://api.github.com/users/ben-page/following{/other_user}","gists_url":"https://api.github.com/users/ben-page/gists{/gist_id}","starred_url":"https://api.github.com/users/ben-page/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben-page/subscriptions","organizations_url":"https://api.github.com/users/ben-page/orgs","repos_url":"https://api.github.com/users/ben-page/repos","events_url":"https://api.github.com/users/ben-page/events{/privacy}","received_events_url":"https://api.github.com/users/ben-page/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ben-page/amqp.node","description":"AMQP 0-9-1 library and client for Node.JS","fork":true,"url":"https://api.github.com/repos/ben-page/amqp.node","forks_url":"https://api.github.com/repos/ben-page/amqp.node/forks","keys_url":"https://api.github.com/repos/ben-page/amqp.node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ben-page/amqp.node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ben-page/amqp.node/teams","hooks_url":"https://api.github.com/repos/ben-page/amqp.node/hooks","issue_events_url":"https://api.github.com/repos/ben-page/amqp.node/issues/events{/number}","events_url":"https://api.github.com/repos/ben-page/amqp.node/events","assignees_url":"https://api.github.com/repos/ben-page/amqp.node/assignees{/user}","branches_url":"https://api.github.com/repos/ben-page/amqp.node/branches{/branch}","tags_url":"https://api.github.com/repos/ben-page/amqp.node/tags","blobs_url":"https://api.github.com/repos/ben-page/amqp.node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ben-page/amqp.node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ben-page/amqp.node/git/refs{/sha}","trees_url":"https://api.github.com/repos/ben-page/amqp.node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ben-page/amqp.node/statuses/{sha}","languages_url":"https://api.github.com/repos/ben-page/amqp.node/languages","stargazers_url":"https://api.github.com/repos/ben-page/amqp.node/stargazers","contributors_url":"https://api.github.com/repos/ben-page/amqp.node/contributors","subscribers_url":"https://api.github.com/repos/ben-page/amqp.node/subscribers","subscription_url":"https://api.github.com/repos/ben-page/amqp.node/subscription","commits_url":"https://api.github.com/repos/ben-page/amqp.node/commits{/sha}","git_commits_url":"https://api.github.com/repos/ben-page/amqp.node/git/commits{/sha}","comments_url":"https://api.github.com/repos/ben-page/amqp.node/comments{/number}","issue_comment_url":"https://api.github.com/repos/ben-page/amqp.node/issues/comments{/number}","contents_url":"https://api.github.com/repos/ben-page/amqp.node/contents/{+path}","compare_url":"https://api.github.com/repos/ben-page/amqp.node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ben-page/amqp.node/merges","archive_url":"https://api.github.com/repos/ben-page/amqp.node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ben-page/amqp.node/downloads","issues_url":"https://api.github.com/repos/ben-page/amqp.node/issues{/number}","pulls_url":"https://api.github.com/repos/ben-page/amqp.node/pulls{/number}","milestones_url":"https://api.github.com/repos/ben-page/amqp.node/milestones{/number}","notifications_url":"https://api.github.com/repos/ben-page/amqp.node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ben-page/amqp.node/labels{/name}","releases_url":"https://api.github.com/repos/ben-page/amqp.node/releases{/id}","created_at":"2015-05-26T19:40:15Z","updated_at":"2015-05-26T19:40:16Z","pushed_at":"2015-05-26T20:10:03Z","git_url":"git://github.com/ben-page/amqp.node.git","ssh_url":"git@github.com:ben-page/amqp.node.git","clone_url":"https://github.com/ben-page/amqp.node.git","svn_url":"https://github.com/ben-page/amqp.node","homepage":null,"size":1700,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"squaremo:master","ref":"master","sha":"be31dd79a8d87475e70ca49ef0d6e247d30b46e4","user":{"login":"squaremo","id":62033,"avatar_url":"https://avatars.githubusercontent.com/u/62033?v=3","gravatar_id":"","url":"https://api.github.com/users/squaremo","html_url":"https://github.com/squaremo","followers_url":"https://api.github.com/users/squaremo/followers","following_url":"https://api.github.com/users/squaremo/following{/other_user}","gists_url":"https://api.github.com/users/squaremo/gists{/gist_id}","starred_url":"https://api.github.com/users/squaremo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squaremo/subscriptions","organizations_url":"https://api.github.com/users/squaremo/orgs","repos_url":"https://api.github.com/users/squaremo/repos","events_url":"https://api.github.com/users/squaremo/events{/privacy}","received_events_url":"https://api.github.com/users/squaremo/received_events","type":"User","site_admin":false},"repo":{"id":10634962,"name":"amqp.node","full_name":"squaremo/amqp.node","owner":{"login":"squaremo","id":62033,"avatar_url":"https://avatars.githubusercontent.com/u/62033?v=3","gravatar_id":"","url":"https://api.github.com/users/squaremo","html_url":"https://github.com/squaremo","followers_url":"https://api.github.com/users/squaremo/followers","following_url":"https://api.github.com/users/squaremo/following{/other_user}","gists_url":"https://api.github.com/users/squaremo/gists{/gist_id}","starred_url":"https://api.github.com/users/squaremo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squaremo/subscriptions","organizations_url":"https://api.github.com/users/squaremo/orgs","repos_url":"https://api.github.com/users/squaremo/repos","events_url":"https://api.github.com/users/squaremo/events{/privacy}","received_events_url":"https://api.github.com/users/squaremo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/squaremo/amqp.node","description":"AMQP 0-9-1 library and client for Node.JS","fork":false,"url":"https://api.github.com/repos/squaremo/amqp.node","forks_url":"https://api.github.com/repos/squaremo/amqp.node/forks","keys_url":"https://api.github.com/repos/squaremo/amqp.node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/squaremo/amqp.node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/squaremo/amqp.node/teams","hooks_url":"https://api.github.com/repos/squaremo/amqp.node/hooks","issue_events_url":"https://api.github.com/repos/squaremo/amqp.node/issues/events{/number}","events_url":"https://api.github.com/repos/squaremo/amqp.node/events","assignees_url":"https://api.github.com/repos/squaremo/amqp.node/assignees{/user}","branches_url":"https://api.github.com/repos/squaremo/amqp.node/branches{/branch}","tags_url":"https://api.github.com/repos/squaremo/amqp.node/tags","blobs_url":"https://api.github.com/repos/squaremo/amqp.node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/squaremo/amqp.node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/squaremo/amqp.node/git/refs{/sha}","trees_url":"https://api.github.com/repos/squaremo/amqp.node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/squaremo/amqp.node/statuses/{sha}","languages_url":"https://api.github.com/repos/squaremo/amqp.node/languages","stargazers_url":"https://api.github.com/repos/squaremo/amqp.node/stargazers","contributors_url":"https://api.github.com/repos/squaremo/amqp.node/contributors","subscribers_url":"https://api.github.com/repos/squaremo/amqp.node/subscribers","subscription_url":"https://api.github.com/repos/squaremo/amqp.node/subscription","commits_url":"https://api.github.com/repos/squaremo/amqp.node/commits{/sha}","git_commits_url":"https://api.github.com/repos/squaremo/amqp.node/git/commits{/sha}","comments_url":"https://api.github.com/repos/squaremo/amqp.node/comments{/number}","issue_comment_url":"https://api.github.com/repos/squaremo/amqp.node/issues/comments{/number}","contents_url":"https://api.github.com/repos/squaremo/amqp.node/contents/{+path}","compare_url":"https://api.github.com/repos/squaremo/amqp.node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/squaremo/amqp.node/merges","archive_url":"https://api.github.com/repos/squaremo/amqp.node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/squaremo/amqp.node/downloads","issues_url":"https://api.github.com/repos/squaremo/amqp.node/issues{/number}","pulls_url":"https://api.github.com/repos/squaremo/amqp.node/pulls{/number}","milestones_url":"https://api.github.com/repos/squaremo/amqp.node/milestones{/number}","notifications_url":"https://api.github.com/repos/squaremo/amqp.node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/squaremo/amqp.node/labels{/name}","releases_url":"https://api.github.com/repos/squaremo/amqp.node/releases{/id}","created_at":"2013-06-12T02:29:36Z","updated_at":"2015-05-26T19:24:16Z","pushed_at":"2015-05-26T20:18:11Z","git_url":"git://github.com/squaremo/amqp.node.git","ssh_url":"git@github.com:squaremo/amqp.node.git","clone_url":"https://github.com/squaremo/amqp.node.git","svn_url":"https://github.com/squaremo/amqp.node","homepage":null,"size":1700,"stargazers_count":404,"watchers_count":404,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":88,"mirror_url":null,"open_issues_count":31,"forks":88,"open_issues":31,"watchers":404,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/squaremo/amqp.node/pulls/159"},"html":{"href":"https://github.com/squaremo/amqp.node/pull/159"},"issue":{"href":"https://api.github.com/repos/squaremo/amqp.node/issues/159"},"comments":{"href":"https://api.github.com/repos/squaremo/amqp.node/issues/159/comments"},"review_comments":{"href":"https://api.github.com/repos/squaremo/amqp.node/pulls/159/comments"},"review_comment":{"href":"https://api.github.com/repos/squaremo/amqp.node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/squaremo/amqp.node/pulls/159/commits"},"statuses":{"href":"https://api.github.com/repos/squaremo/amqp.node/statuses/8b08adaa5404e29264f59b2cd314bc92a53f515f"}}}}