Support for non-friendly chars in url username and password (#858)
* Support for non-friendly chars in url username and password - Added auth option to Connection class - Updated pool.addConnection * Updated test
This commit is contained in:
committed by
delvedor
parent
9897ba8831
commit
bb0ff22fd2
@ -222,21 +222,24 @@ class ConnectionPool {
|
||||
// we can add it to them once the connection instance has been created
|
||||
if (opts.url.username !== '' && opts.url.password !== '') {
|
||||
this._auth = {
|
||||
username: opts.url.username,
|
||||
password: opts.url.password
|
||||
username: decodeURIComponent(opts.url.username),
|
||||
password: decodeURIComponent(opts.url.password)
|
||||
}
|
||||
opts.auth = this._auth
|
||||
}
|
||||
|
||||
if (this._auth != null) {
|
||||
if (opts.auth == null || (opts.auth.username == null && opts.auth.password == null)) {
|
||||
opts.auth = this._auth
|
||||
opts.url.username = this._auth.username
|
||||
opts.url.password = this._auth.password
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.ssl == null) opts.ssl = this._ssl
|
||||
if (opts.agent == null) opts.agent = this._agent
|
||||
|
||||
const connection = new this.Connection(opts)
|
||||
if (connection.url.username === '' &&
|
||||
connection.url.password === '' &&
|
||||
this._auth != null) {
|
||||
connection.url.username = this._auth.username
|
||||
connection.url.password = this._auth.password
|
||||
}
|
||||
|
||||
debug('Adding a new connection', connection)
|
||||
if (this.connections.has(connection.id)) {
|
||||
throw new Error(`Connection with id '${connection.id}' is already present`)
|
||||
|
||||
Reference in New Issue
Block a user