@@ -366,33 +366,24 @@ export async function getReleaseNotesMd(
366366 . replace ( regEx ( / ^ \s * # * \s * / ) , '' )
367367 . split ( ' ' )
368368 . filter ( Boolean ) ;
369- let body = section . replace ( regEx ( / .* ?\n ( - { 3 , } \n ) ? / ) , '' ) . trim ( ) ;
369+ const body = section . replace ( regEx ( / .* ?\n ( - { 3 , } \n ) ? / ) , '' ) . trim ( ) ;
370+ const notesSourceUrl = getNotesSourceUrl (
371+ baseUrl ,
372+ repository ,
373+ project ,
374+ changelogFile ,
375+ ) ;
376+ const mdHeadingLink = title
377+ . filter ( ( word ) => ! isHttpUrl ( word ) )
378+ . join ( '-' )
379+ . replace ( regEx ( / [ ^ A - Z a - z 0 - 9 - ] / g) , '' ) ;
380+ const url = `${ notesSourceUrl } #${ mdHeadingLink } ` ;
381+ // Look for version in title
370382 for ( const word of title ) {
371383 if ( word . includes ( version ) && ! isHttpUrl ( word ) ) {
372384 logger . trace ( { body } , 'Found release notes for v' + version ) ;
373- const notesSourceUrl = getNotesSourceUrl (
374- baseUrl ,
375- repository ,
376- project ,
377- changelogFile ,
378- ) ;
379- const mdHeadingLink = title
380- . filter ( ( word ) => ! isHttpUrl ( word ) )
381- . join ( '-' )
382- . replace ( regEx ( / [ ^ A - Z a - z 0 - 9 - ] / g) , '' ) ;
383- const url = `${ notesSourceUrl } #${ mdHeadingLink } ` ;
384- body = massageBody ( body , baseUrl ) ;
385- if ( body ?. length ) {
386- try {
387- body = await linkify ( body , {
388- repository : `${ baseUrl } ${ repository } ` ,
389- } ) ;
390- } catch ( err ) /* istanbul ignore next */ {
391- logger . warn ( { body, err } , 'linkify error' ) ;
392- }
393- }
394385 return {
395- body,
386+ body : await linkifyBody ( project , body ) ,
396387 url,
397388 notesSourceUrl,
398389 } ;
@@ -524,3 +515,20 @@ function getNotesSourceUrl(
524515 changelogFile ,
525516 ) ;
526517}
518+
519+ async function linkifyBody (
520+ { baseUrl, repository } : ChangeLogProject ,
521+ bodyStr : string ,
522+ ) : Promise < string > {
523+ const body = massageBody ( bodyStr , baseUrl ) ;
524+ if ( body ?. length ) {
525+ try {
526+ return await linkify ( body , {
527+ repository : `${ baseUrl } ${ repository } ` ,
528+ } ) ;
529+ } catch ( err ) /* istanbul ignore next */ {
530+ logger . warn ( { body, err } , 'linkify error' ) ;
531+ }
532+ }
533+ return body ;
534+ }
0 commit comments