@@ -16,20 +16,25 @@ client.once('ready', () => {
1616WebhookEvent . on ( 'post' , async ( post : Message ) => {
1717 console . log ( post ) ;
1818
19- const regexInner = `.+(?: \\/ .+)*?(?=]\\(https:\\/\\/gitlab\\.com\\/${ process . env . GITLAB_ORG_NAME . toLowerCase ( ) } \\/[a-z\\-\\/]+\\)` ;
19+ const regexInner = `.+(?: \\/ .+)*?(?=]\\(https:\\/\\/gitlab\\.com\\/${ process . env . GITLAB_ORG_NAME . toLowerCase ( ) } \\/( [a-z\\-\\/]+) \\)` ;
2020 const regex = new RegExp ( `(?<=\\[${ process . env . GITLAB_ORG_NAME } / )${ regexInner } )|(?<=\\[)${ regexInner } : Pipeline)` ) ;
2121
2222 const matches = post . embeds [ 0 ] . description . match ( regex ) ;
2323
2424 if ( ! matches ) return ;
2525
26- if ( post . embeds [ 0 ] . description . match ( / P i p e l i n e / ) ) {
26+ matches [ 0 ] = matches [ 0 ] . replace ( new RegExp ( `${ process . env . GITLAB_ORG_NAME } /(?: .*? \\/)* ` ) , '' ) . replace ( / \/ / g, '–' ) ;
27+
28+ const urlify = string => string . toLowerCase ( ) . replace ( / / g, '-' ) . replace ( / - + / g, '-' ) . replace ( / - * – - * / , '/' ) ;
29+
30+ const isPipeline = post . embeds [ 0 ] . description . match ( / P i p e l i n e / ) ;
31+
32+ if ( isPipeline ) {
2733 if ( post . embeds [ 0 ] . description . match ( / p a s s e d / ) ) post . embeds [ 0 ] . color = 123456 ;
2834 else if ( post . embeds [ 0 ] . description . match ( / f a i l e d / ) ) post . embeds [ 0 ] . color = 16711680 ;
35+ matches [ 0 ] = urlify ( matches [ 2 ] ) ;
2936 }
3037
31- matches [ 0 ] = matches [ 0 ] . replace ( new RegExp ( `${ process . env . GITLAB_ORG_NAME } /(?: .*? \\/)* ` ) , '' ) . replace ( / \/ / g, '–' ) ;
32-
3338 const channel = ( await client . channels . fetch (
3439 process . env . CHANNEL_ID
3540 ) ) as TextChannel ;
@@ -40,7 +45,7 @@ WebhookEvent.on('post', async (post: Message) => {
4045 ( await channel . threads . fetchArchived ( { fetchAll : true } , false ) ) . threads
4146 ) ;
4247
43- let thread = allThreads . find ( ( th ) => th . name === matches [ 0 ] ) ;
48+ let thread = allThreads . find ( ( th ) => ( isPipeline ? urlify ( th . name ) : th . name ) === matches [ 0 ] ) ;
4449
4550 thread ??= await channel . threads . create ( {
4651 name : matches [ 0 ] ,
0 commit comments