From ffaafd855609756a6be4715bc91aa4e9c294974c Mon Sep 17 00:00:00 2001 From: smessie Date: Mon, 7 Oct 2024 17:34:59 +0200 Subject: [PATCH] fix: No mGet for zero members and escape more chars --- src/repositories/RedisRepository.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/repositories/RedisRepository.ts b/src/repositories/RedisRepository.ts index c5a977c..d1453b7 100644 --- a/src/repositories/RedisRepository.ts +++ b/src/repositories/RedisRepository.ts @@ -69,6 +69,9 @@ export class RedisRepository implements Repository { } async findMembers(members: string[]): Promise { + if (members.length === 0) { + return []; + } return (await this.client?.mGet(members.map((member) => `${this.data}:${encodeURIComponent(member)}`)) ?? []) .filter((entry) => entry !== null) .map((entry, i) => { @@ -115,7 +118,7 @@ export class RedisRepository implements Repository { } encodeKey(key: string): string { - // Add \\ in front of ., :, /, - - return key.replace(/([.:\/-])/g, "\\$1"); + // Add \\ in front of ., :, /, -, _, % + return key.replace(/([.:\/\-_%])/g, "\\$1"); } }