File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -26,15 +26,17 @@ export interface RoomStreamInfos {
2626 room : string ;
2727 docid : string ;
2828}
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 } "` ) ;
3537 }
3638
37- return { room : decodeURIComponent ( match [ 2 ] ) , docid : decodeURIComponent ( match [ 3 ] ) } ;
39+ return { room : decodeURIComponent ( match [ 1 ] ) , docid : decodeURIComponent ( match [ 2 ] ) } ;
3840} ;
3941
4042const getIdFromLastStreamMessageReply = ( docStreamReplay : StreamMessagesReply ) : RedisKey | undefined => {
You can’t perform that action at this time.
0 commit comments