@@ -185,7 +185,7 @@ export const isOrganizationProfile = (): boolean => exists('meta[name="hovercard
185
185
186
186
export const isOrganizationRepo = ( ) : boolean => Boolean ( document . querySelector < HTMLElement > ( '[data-owner-scoped-search-url]' ) ?. dataset [ 'ownerScopedSearchUrl' ] ! . startsWith ( '/org' ) ) ;
187
187
188
- export const isTeamDiscussion = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ o r g s \/ [ ^ / ] + \/ t e a m s \/ [ ^ / ] + ( $ | \/ d i s c u s s i o n s ) / . test ( getCleanPathname ( url ) ) ;
188
+ export const isTeamDiscussion = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => Boolean ( getOrg ( url ) ?. path . startsWith ( 'teams' ) ) ;
189
189
addTests ( 'isTeamDiscussion' , [
190
190
'https://github.com/orgs/refined-github/teams/core-team/discussions?pinned=1' ,
191
191
'https://github.com/orgs/refined-github/teams/core-team/discussions/1' ,
@@ -207,14 +207,16 @@ addTests('isProjects', [
207
207
'https://github.com/sindresorhus/refined-github/projects' ,
208
208
] ) ;
209
209
210
- export const isDiscussion = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ d i s c u s s i o n s \/ \d + / . test ( getRepo ( url ) ?. path ! ) ;
210
+ export const isDiscussion = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ d i s c u s s i o n s \/ \d + / . test ( getRepo ( url ) ?. path ?? getOrg ( url ) ?. path ! ) ;
211
211
addTests ( 'isDiscussion' , [
212
212
'https://github.com/tophf/mpiv/discussions/50' ,
213
+ 'https://github.com/orgs/community/discussions/11202' ,
213
214
] ) ;
214
215
215
- export const isDiscussionList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => getRepo ( url ) ?. path === 'discussions' ;
216
+ export const isDiscussionList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => getRepo ( url ) ?. path === 'discussions' || getOrg ( url ) ?. path === 'discussions' ;
216
217
addTests ( 'isDiscussionList' , [
217
218
'https://github.com/tophf/mpiv/discussions' ,
219
+ 'https://github.com/orgs/community/discussions' ,
218
220
] ) ;
219
221
220
222
export const isPR = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + / . test ( getRepo ( url ) ?. path ! ) && ! isPRConflicts ( url ) ;
@@ -728,6 +730,15 @@ const getCleanGistPathname = (url: URL | HTMLAnchorElement | Location = location
728
730
return gist === 'gist' ? parts . join ( '/' ) : undefined ;
729
731
} ;
730
732
733
+ const getOrg = ( url : URL | HTMLAnchorElement | Location = location ) : { name : string ; path : string } | undefined => {
734
+ const [ , orgs , name , ...path ] = url . pathname . split ( '/' ) ;
735
+ if ( orgs === 'orgs' && name ) {
736
+ return { name, path : path . join ( '/' ) } ;
737
+ }
738
+
739
+ return undefined ;
740
+ } ;
741
+
731
742
export type RepositoryInfo = {
732
743
owner : string ;
733
744
name : string ;
0 commit comments