Skip to content

Commit d59110a

Browse files
committed
Adds utility to escape special Redis tag characters
Introduces a helper to properly escape reserved characters in Redis tags, improving query reliability and preventing parsing errors during tag searches. References official Redis documentation for escaping conventions.
1 parent b8c0dd6 commit d59110a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/redis/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ export const Redis = (() => {
4040
},
4141
}
4242
})()
43+
44+
// reference: https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/escaping/
45+
export const escapeTag = (tag?: string) =>
46+
tag?.replace(/[,.<>{}[]"':;!@#$%^&*()-+=~]/g, '\\$&')

0 commit comments

Comments
 (0)