File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1+ import { normalizePrefixGlob } from '../normalizePrefixGlob' ;
2+
3+ describe ( 'normalizePrefixGlob' , ( ) => {
4+ it ( 'check simple mask' , ( ) => {
5+ expect ( normalizePrefixGlob ( 'bull*' ) ) . toBe ( 'bull*:*:meta' ) ;
6+ expect ( normalizePrefixGlob ( 'bull' ) ) . toBe ( 'bull:*:meta' ) ;
7+ } ) ;
8+
9+ it ( 'check mask with queue name prefix' , ( ) => {
10+ expect ( normalizePrefixGlob ( 'bull:metrics*' ) ) . toBe ( 'bull:metrics*:meta' ) ;
11+ } ) ;
12+
13+ it ( 'check mask with queue name' , ( ) => {
14+ expect ( normalizePrefixGlob ( 'bull:metrics' ) ) . toBe ( 'bull:metrics:meta' ) ;
15+ } ) ;
16+
17+ it ( 'check mask with prefix which contains semicolons' , ( ) => {
18+ expect ( normalizePrefixGlob ( 'my:service:bull:metrics' ) ) . toBe ( 'my:service:bull:metrics:meta' ) ;
19+ } ) ;
20+ } ) ;
Original file line number Diff line number Diff line change 11export function normalizePrefixGlob ( prefixGlob : string ) : string {
22 let prefixGlobNorm = prefixGlob ;
3- const nameCase = prefixGlobNorm . split ( ':' ) . length - 1 ;
4- if ( nameCase >= 2 ) {
5- prefixGlobNorm = prefixGlobNorm . split ( ':' ) . slice ( 0 , 2 ) . join ( ':' ) + ':' ;
6- } else if ( nameCase === 1 ) {
3+ const nameCase = prefixGlobNorm . split ( ':' ) ;
4+ if ( nameCase . length >= 3 ) {
5+ prefixGlobNorm = nameCase . filter ( ( s ) => s !== '' ) . join ( ':' ) + ':' ;
6+ } else if ( nameCase . length === 2 ) {
77 prefixGlobNorm += prefixGlobNorm . endsWith ( ':' ) ? '*:' : ':' ;
88 } else {
99 prefixGlobNorm += ':*:' ;
You can’t perform that action at this time.
0 commit comments