@@ -50,11 +50,6 @@ export function generateGitHubWebUrl(
50
50
newUrl = newUrl . replace ( '/pulls/' , '/pull/' ) ;
51
51
}
52
52
53
- if ( newUrl . indexOf ( '/releases/' ) !== - 1 ) {
54
- newUrl = newUrl . replace ( '/repos' , '' ) ;
55
- newUrl = newUrl . substring ( 0 , newUrl . lastIndexOf ( '/' ) ) ;
56
- }
57
-
58
53
if ( userId ) {
59
54
const notificationReferrerId = generateNotificationReferrerId (
60
55
notificationId ,
@@ -73,6 +68,14 @@ const addHours = (date: string, hours: number) =>
73
68
const queryString = ( repo : string , title : string , lastUpdated : string ) =>
74
69
`${ title } in:title repo:${ repo } updated:>${ addHours ( lastUpdated , - 2 ) } ` ;
75
70
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
+
76
79
async function getDiscussionUrl (
77
80
notification : Notification ,
78
81
token : string ,
@@ -155,16 +158,15 @@ export async function openInBrowser(
155
158
notification : Notification ,
156
159
accounts : AuthState ,
157
160
) {
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
+ ) ,
168
170
) ,
169
171
) ;
170
172
} else if ( notification . subject . type === 'Discussion' ) {
@@ -181,5 +183,17 @@ export async function openInBrowser(
181
183
) ,
182
184
) ,
183
185
) ;
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
+ ) ;
184
198
}
185
199
}
0 commit comments