File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -26,15 +26,17 @@ export interface RoomStreamInfos {
26
26
room : string ;
27
27
docid : string ;
28
28
}
29
- export const decodeRedisRoomStreamName = ( rediskey : string , expectedPrefix : string ) : RoomStreamInfos => {
30
- const match = / ^ ( .* ) : r o o m : ( .* ) : ( .* ) $ / . exec ( rediskey ) ;
31
- if ( match == null || match [ 1 ] !== expectedPrefix ) {
32
- throw new Error (
33
- `Malformed stream name! prefix="${ match ?. [ 1 ] } " expectedPrefix="${ expectedPrefix } ", rediskey="${ rediskey } "` ,
34
- ) ;
29
+
30
+ export const decodeRedisRoomStreamName = ( rediskey : string , expectedRedisPrefix : string ) : RoomStreamInfos => {
31
+ const match = new RegExp ( `^${ expectedRedisPrefix } :room:([^:]+):([^:]+)$` ) . exec ( rediskey ) ;
32
+ console . log ( 'match' , match ) ;
33
+ console . log ( 'expectedRedisPrefix' , expectedRedisPrefix ) ;
34
+
35
+ if ( match == null ) {
36
+ throw new Error ( `Malformed stream name! expectedRedisPrefix="${ expectedRedisPrefix } ", rediskey="${ rediskey } "` ) ;
35
37
}
36
38
37
- return { room : decodeURIComponent ( match [ 2 ] ) , docid : decodeURIComponent ( match [ 3 ] ) } ;
39
+ return { room : decodeURIComponent ( match [ 1 ] ) , docid : decodeURIComponent ( match [ 2 ] ) } ;
38
40
} ;
39
41
40
42
const getIdFromLastStreamMessageReply = ( docStreamReplay : StreamMessagesReply ) : RedisKey | undefined => {
You can’t perform that action at this time.
0 commit comments