Skip to content

Commit 57fd2f5

Browse files
committed
fix: pick username from Connection options
1 parent 865126c commit 57fd2f5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/socket.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,11 @@ export const Socket = (
229229
function redisOptsFromConnection(connection: Connection): RedisOptions {
230230
let opts: RedisOptions = {
231231
...pick(connection, [
232-
"port",
233232
"host",
234-
"family",
233+
"port",
234+
"username",
235235
"password",
236+
"family",
236237
"sentinelPassword",
237238
"db",
238239
"tls",
@@ -264,6 +265,8 @@ function redisOptsFromUrl(urlString: string) {
264265
? parseInt(redisUrl.pathname.split("/")[1])
265266
: 0;
266267
if (redisUrl.auth) {
268+
const username = redisUrl.auth.split(":")[0];
269+
redisOpts.username = username ? username : undefined;
267270
redisOpts.password = redisUrl.auth.split(":")[1];
268271
}
269272
} catch (e) {

0 commit comments

Comments
 (0)