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

Accept url.parse()-compatible object as input #3

Open
stevenvachon opened this issue Jun 17, 2015 · 3 comments
Open

Accept url.parse()-compatible object as input #3

stevenvachon opened this issue Jun 17, 2015 · 3 comments
Assignees
Milestone

Comments

@stevenvachon
Copy link

... in addition to a url string. Good for increased performance when we already have a parsed url handy.

@joepie91 joepie91 self-assigned this Jul 15, 2015
@joepie91
Copy link
Owner

What are your thoughts on accepting a url.parse object in place of a URL string, ie. as the first argument? This would remove the need to add yet another option.

@stevenvachon
Copy link
Author

It doesn't need to be an option. It could check the type of input:

var url = require("url");

if (typeof input==="string" || input instanceof String===true) {
    input = url.parse(input);
} else if (input instanceof url.constructor !== true) {
    // error
}

This isn't exactly url.parse()-compatible, though. Could also more simply check typeof input==="object" && input.protocol!=null.

Continuing with string input can be convenient and cleaner for most libraries. Also increases similarity with "request" lib.

@joepie91 joepie91 added this to the feature-next milestone Aug 18, 2015
@stevenvachon
Copy link
Author

Use whatwg-url. In Node v7, it'll be accessible via require("url").URL.

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

No branches or pull requests

2 participants