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

Replace url-parse lib with native URL interface #678

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jonaswalden
Copy link

@jonaswalden jonaswalden commented Apr 9, 2022

Engine specified to node >= 10.
Should be no need for a lib to polyfill the URL interface or implement the legacy url.parse in a browser environment.

};

fields = openFrames(url.vhost, config, sockopts.credentials || credentials.plain(user, pass), extraClientProperties);
fields = openFrames(url.vhost, url.searchParams, sockopts.credentials || credentials.plain(user, pass), extraClientProperties);
Copy link
Author

@jonaswalden jonaswalden Apr 9, 2022

Choose a reason for hiding this comment

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

CAUTION (maybe) vhost used here is not a part of a URL instance.
Then again it wasn't a part of the legacy url.parse / url-parse result either so this was undefined anyway. The only place I found where it wasn't undefined was in the bad URL test.

Copy link
Collaborator

@kibertoad kibertoad Jan 16, 2023

Choose a reason for hiding this comment

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

this sounds like a bug. can we fix it? vhost is important
or you mean that there is no way to include vhost in url?
amqp://${config.username}:${config.password}@${config.hostname}:${config.port}/${config.vhost} is a commonly used structure for amqp urls, and, to my knowledge, currently it works.

@cressie176
Copy link
Collaborator

Thanks @jonaswalden.

7acbfd7 details why url-parse was introduced in the first place. I suspect that now amqplib only supports node 10 and up, the standard url parser will be fine. Unless this isn't so, I'm in favour of this PR - the fewer 3rd party libs we import the better

@kibertoad
Copy link
Collaborator

@jonaswalden Could you please rebase this?

@jonaswalden
Copy link
Author

@cressie176 wow, ok. good to know! seems like that's covered https://github.com/BonnierNews/amqplib/blob/main/test/connect.js#L54

@jonaswalden
Copy link
Author

hold on, I screwed something up

@jonaswalden
Copy link
Author

jonaswalden commented Jun 23, 2022

hold on, I screwed something up

solved.

@kibertoad good to go?

@@ -104,37 +103,30 @@ function connect(url, socketOptions, openCallback) {

var protocol, fields;
if (typeof url === 'object') {
protocol = (url.protocol || 'amqp') + ':';
protocol = url.protocol || 'amqp:';
Copy link
Collaborator

Choose a reason for hiding this comment

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

protocol no longer gets : appended to it, is it intentional?

@@ -29,27 +29,27 @@ suite("Credentials", function() {
}

test("no creds", function(done) {
var parts = urlparse('amqp://localhost');
var parts = new URL('amqp://localhost');
var creds = credentialsFromUrl(parts);
checkCreds(creds, 'guest', 'guest', done);
});
test("usual user:pass", function(done) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add test case for the vhost, using the
amqp://${config.username}:${config.password}@${config.hostname}:${config.port}/${config.vhost} structure?

@kibertoad
Copy link
Collaborator

@jonaswalden Do you need any help with finishing 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.

3 participants