File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { replaceUrlInTextNodes } from "./replaceUrlInTextNodes";
22
33type UnfurlerObject < T > = {
44 parseUrl : ( url : URL ) => T | null | undefined ;
5- buildTitle : ( params : T ) => string | Promise < string > ;
5+ buildTitle : ( params : T , url : URL ) => string | Promise < string > ;
66} ;
77
88export const defineUnfurler = < T > ( unfurler : UnfurlerObject < T > ) => {
@@ -11,6 +11,6 @@ export const defineUnfurler = <T>(unfurler: UnfurlerObject<T>) => {
1111 const parsed = unfurler . parseUrl ( url ) ;
1212 if ( ! parsed ) return ;
1313
14- replaceUrlInTextNodes ( el , await unfurler . buildTitle ( parsed ) ) ;
14+ replaceUrlInTextNodes ( el , await unfurler . buildTitle ( parsed , url ) ) ;
1515 } ;
1616} ;
Original file line number Diff line number Diff line change @@ -11,7 +11,12 @@ const PULL_REQUEST_NUMBER_REGEX = "(?<number>[0-9]+)" as const;
1111export const issueUnfurler = defineUnfurler ( {
1212 parseUrl : ( url ) =>
1313 regex ( `^/view/${ ISSUE_KEY_REGEX } $` ) . exec ( url . pathname ) ?. groups ,
14- buildTitle : ( params ) => `Issue: ${ params . issueKey } ` ,
14+ buildTitle : ( params , url ) => {
15+ if ( url . hash . startsWith ( "#comment-" ) ) {
16+ return `Comment on ${ params . issueKey } ` ;
17+ }
18+ return `Issue: ${ params . issueKey } ` ;
19+ } ,
1520} ) ;
1621
1722export const wikiUnfurler = defineUnfurler ( {
@@ -33,6 +38,10 @@ export const pullRequestUnfurler = defineUnfurler({
3338 regex (
3439 `^/git/${ PROJECT_KEY_REGEX } /${ REPOSITORY_REGEX } /pullRequests/${ PULL_REQUEST_NUMBER_REGEX } $` ,
3540 ) . exec ( url . pathname ) ?. groups ,
36- buildTitle : ( params ) =>
37- `Pull Request: ${ params . projectKey } /${ params . repository } #${ params . number } ` ,
41+ buildTitle : ( params , url ) => {
42+ if ( url . hash . startsWith ( "#comment-" ) ) {
43+ return `Comment on Pull Request #${ params . number } ` ;
44+ }
45+ return `Pull Request #${ params . number } ` ;
46+ } ,
3847} ) ;
You can’t perform that action at this time.
0 commit comments