Open stevenvachon opened 9 years ago
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.
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.
Use whatwg-url. In Node v7, it'll be accessible via require("url").URL
.
... in addition to a url string. Good for increased performance when we already have a parsed url handy.