File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,22 @@ export function parseTicketIds(minCount: number = 1): string[] {
1414 . map ( ( id ) => id . trim ( ) )
1515 . filter ( ( id ) => id . length > 0 ) ;
1616
17+ // Check for duplicates
18+ const uniqueTicketIds = new Set ( ticketIds ) ;
19+ if ( uniqueTicketIds . size !== ticketIds . length ) {
20+ const duplicates = ticketIds . filter ( ( item , index ) => ticketIds . indexOf ( item ) !== index ) ;
21+ const uniqueDuplicates = Array . from ( new Set ( duplicates ) ) ;
22+ throw new Error ( `Duplicate ticket IDs found: ${ uniqueDuplicates . join ( ", " ) } ` ) ;
23+ }
24+
1725 if ( ticketIds . length < minCount ) {
1826 throw new Error ( `Not enough tickets provided! Found ${ ticketIds . length } but need at least ${ minCount } .` ) ;
1927 }
2028
29+ console . log ( "\nParsed Ticket IDs:" ) ;
30+ ticketIds . forEach ( ( id , index ) => {
31+ console . log ( ` ${ ( index + 1 ) . toString ( ) . padStart ( 2 , " " ) } . ${ id } ` ) ;
32+ } ) ;
33+
2134 return ticketIds ;
2235}
You can’t perform that action at this time.
0 commit comments