mongo-uri-builder
mongo-uri-builder copied to clipboard
Password contains an illegal unescaped character
I've reviewed this and confirmed it's a bug. The password should be URI-encoded, but this library does not current encode it, nor document that a pre-encoded value should be provided.
I believe the fix is to add encodeURIComponent(config.password)
to the built string instead of just config.password
.
But I also recommend this workaround: Generate passwords in the first place that don't use any of the reserved characters used by URI Encoding so that they don't require encoding. This is easy to do with the crypto-random-string
module which has a uri-safe
option for this purpose.
Can be closed as a duplicate of #2.