From 57fd2f5fc958ea49adfd72c90d8cfd99def5e55f Mon Sep 17 00:00:00 2001 From: Manuel Astudillo Date: Thu, 20 Apr 2023 15:49:44 +0200 Subject: [PATCH] fix: pick username from Connection options --- lib/socket.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/socket.ts b/lib/socket.ts index e9c5b44..c8729a5 100644 --- a/lib/socket.ts +++ b/lib/socket.ts @@ -229,10 +229,11 @@ export const Socket = ( function redisOptsFromConnection(connection: Connection): RedisOptions { let opts: RedisOptions = { ...pick(connection, [ - "port", "host", - "family", + "port", + "username", "password", + "family", "sentinelPassword", "db", "tls", @@ -264,6 +265,8 @@ function redisOptsFromUrl(urlString: string) { ? parseInt(redisUrl.pathname.split("/")[1]) : 0; if (redisUrl.auth) { + const username = redisUrl.auth.split(":")[0]; + redisOpts.username = username ? username : undefined; redisOpts.password = redisUrl.auth.split(":")[1]; } } catch (e) {