url.parse and URL (it just throws) don't handle urls with multiple hosts
var u = url.parse('mongodb://server1.db.foo.net:27017,server2.db.foo.net:27017,server3.db.foo.net:27017/data?authMechanism=MONGO-X509&replicaSet=rs0&ssl=true&sslValidate=true', true)
/*
Url {
protocol: 'https:',
slashes: true,
auth: 'foo',
host: 'server1.foo.net:7998',
port: '7998',
hostname: 'server1.foo.net',
hash: null,
search:
'?authMechanism=X509&replicaSet=rs0&ssl=true&sslValidate=true',
query:
{ authMechanism: 'X509',
replicaSet: 'rs0',
ssl: 'true',
sslValidate: 'true' },
pathname: '/:7998,server2.foo.net:7998,server3.foo.net/data',
path:
'/:7998,server2.foo.net:7998,server3.foo.net/data?authMechanism=X509&replicaSet=rs0&ssl=true&sslValidate=true',
// ...
*/
python can handle them: https://github.com/whatwg/url/issues/398#issuecomment-401348316
So I wonder if it couldn't be something we can change in node?
Given that this is not standard URL syntax (for both IETF and WHATWG specs)... this is not a syntax Node.js likely to support natively. At this point, the older url.parse() is legacy and not likely to be significantly updated and the WHATWG URL implementation is guided by the WHATWG specification in order to maintain compatibility.
For Node.js, the best bet for this would be implementation of a userland module that handles these.
I think this isn't something Node should take up, thought it might be something https://url.spec.whatwg.org/ could be amended to support.
Closing given the response
Most helpful comment
Given that this is not standard URL syntax (for both IETF and WHATWG specs)... this is not a syntax Node.js likely to support natively. At this point, the older
url.parse()is legacy and not likely to be significantly updated and the WHATWGURLimplementation is guided by the WHATWG specification in order to maintain compatibility.For Node.js, the best bet for this would be implementation of a userland module that handles these.