the method createConnection accepts a connection URL as a string or an object of type ConnectionConfig
if a string is passed, it uses require('url').parse to parse the string and returns a connection object.
this approach assumes that the property pathname that is returned by url.parse has a string value, but in fact, it returns null when providing a port which is an integer
example
let's parse this connection URL string mysql://username:password@host:1234
Good catch. We can fix the module to properly handle null, as it should be the same as just no database like otherwise. Sorry for that bug, it is an easy fix.
the method
createConnection
accepts a connection URL as a string or an object of typeConnectionConfig
if a string is passed, it usesrequire('url').parse
to parse the string and returns a connection object.this approach assumes that the property
pathname
that is returned byurl.parse
has a string value, but in fact, it returns null when providing a port which is an integerexample let's parse this connection URL string
mysql://username:password@host:1234
output:
note that
pathname
here is null