@@ -50,11 +50,6 @@ export function generateGitHubWebUrl(
5050 newUrl = newUrl . replace ( '/pulls/' , '/pull/' ) ;
5151 }
5252
53- if ( newUrl . indexOf ( '/releases/' ) !== - 1 ) {
54- newUrl = newUrl . replace ( '/repos' , '' ) ;
55- newUrl = newUrl . substring ( 0 , newUrl . lastIndexOf ( '/' ) ) ;
56- }
57-
5853 if ( userId ) {
5954 const notificationReferrerId = generateNotificationReferrerId (
6055 notificationId ,
@@ -73,6 +68,14 @@ const addHours = (date: string, hours: number) =>
7368const queryString = ( repo : string , title : string , lastUpdated : string ) =>
7469 `${ title } in:title repo:${ repo } updated:>${ addHours ( lastUpdated , - 2 ) } ` ;
7570
71+ async function getReleaseTagWebUrl ( notification : Notification , token : string ) {
72+ const response = await apiRequestAuth ( notification . subject . url , 'GET' , token ) ;
73+
74+ return {
75+ url : response . data . html_url ,
76+ } ;
77+ }
78+
7679async function getDiscussionUrl (
7780 notification : Notification ,
7881 token : string ,
@@ -155,16 +158,15 @@ export async function openInBrowser(
155158 notification : Notification ,
156159 accounts : AuthState ,
157160) {
158- if ( notification . subject . url ) {
159- const latestCommentId = getCommentId (
160- notification . subject . latest_comment_url ,
161- ) ;
162- openExternalLink (
163- generateGitHubWebUrl (
164- notification . subject . url ,
165- notification . id ,
166- accounts . user ?. id ,
167- latestCommentId ? '#issuecomment-' + latestCommentId : undefined ,
161+ if ( notification . subject . type === 'Release' ) {
162+ getReleaseTagWebUrl ( notification , accounts . token ) . then ( ( { url } ) =>
163+ openExternalLink (
164+ generateGitHubWebUrl (
165+ url ,
166+ notification . id ,
167+ accounts . user ?. id ,
168+ undefined ,
169+ ) ,
168170 ) ,
169171 ) ;
170172 } else if ( notification . subject . type === 'Discussion' ) {
@@ -181,5 +183,17 @@ export async function openInBrowser(
181183 ) ,
182184 ) ,
183185 ) ;
186+ } else if ( notification . subject . url ) {
187+ const latestCommentId = getCommentId (
188+ notification . subject . latest_comment_url ,
189+ ) ;
190+ openExternalLink (
191+ generateGitHubWebUrl (
192+ notification . subject . url ,
193+ notification . id ,
194+ accounts . user ?. id ,
195+ latestCommentId ? '#issuecomment-' + latestCommentId : undefined ,
196+ ) ,
197+ ) ;
184198 }
185199}
0 commit comments