Skip to content

Commit

Permalink
fix: No mGet for zero members and escape more chars
Browse files Browse the repository at this point in the history
  • Loading branch information
smessie committed Oct 7, 2024
1 parent d2ce7d7 commit ffaafd8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/repositories/RedisRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export class RedisRepository implements Repository {
}

async findMembers(members: string[]): Promise<Member[]> {
if (members.length === 0) {
return [];
}
return (await this.client?.mGet(members.map((member) => `${this.data}:${encodeURIComponent(member)}`)) ?? [])
.filter((entry) => entry !== null)
.map((entry, i) => {
Expand Down Expand Up @@ -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");
}
}

0 comments on commit ffaafd8

Please sign in to comment.