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

URL with omitted protocol is not parsed properly. #5

Open
akayami opened this issue May 26, 2014 · 2 comments
Open

URL with omitted protocol is not parsed properly. #5

akayami opened this issue May 26, 2014 · 2 comments

Comments

@akayami
Copy link

akayami commented May 26, 2014

Hi,

I've been working with the url extension and noticed it does not parse properly URL that do not contain protocol:

var url = require('url');
console.log(url.parse('//test.com/path?query=value'));

Is this a bug ?

@defunctzombie
Copy link
Owner

This is mostly a copy of the node.js url code. Do they have an open issue about this?

https://github.com/joyent/node

@theetrain
Copy link

I ran into this issue myself, and the solution was right under my nose. Change your code to:

var url = require('url');
console.log(url.parse('//test.com/path?query=value', false, true));

This will parse the host and hostname correctly, but bear in mind the returned object.protocol will be null. More details in the node docs: https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost

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

No branches or pull requests

3 participants