1
- import reservedNames from 'github-reserved-names/reserved-names.json' assert { type : 'json' } ;
1
+ import reservedNames from 'github-reserved-names/reserved-names.json' with { type : 'json' } ;
2
2
import { addTests } from './collector.js' ;
3
3
4
4
const $ = < E extends Element > ( selector : string ) => document . querySelector < E > ( selector ) ;
@@ -130,7 +130,7 @@ addTests('isGlobalSearchResults', [
130
130
'https://github.com/search?q=refined-github&ref=opensearch' ,
131
131
] ) ;
132
132
133
- export const isIssue = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ i s s u e s \/ \d + / . test ( getRepo ( url ) ?. path ! ) && document . title !== 'GitHub · Where software is built' ; // The title check excludes deleted issues
133
+ export const isIssue = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ i s s u e s \/ \d + / . test ( getRepo ( url ) ?. path ) && document . title !== 'GitHub · Where software is built' ; // The title check excludes deleted issues
134
134
addTests ( 'isIssue' , [
135
135
'https://github.com/sindresorhus/refined-github/issues/146' ,
136
136
] ) ;
@@ -150,7 +150,7 @@ addTests('isLabelList', [
150
150
'https://github.com/sindresorhus/refined-github/labels/' ,
151
151
] ) ;
152
152
153
- export const isMilestone = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ m i l e s t o n e \/ \d + / . test ( getRepo ( url ) ?. path ! ) ;
153
+ export const isMilestone = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ m i l e s t o n e \/ \d + / . test ( getRepo ( url ) ?. path ) ;
154
154
addTests ( 'isMilestone' , [
155
155
'https://github.com/kubernetes/kubernetes/milestone/56' ,
156
156
] ) ;
@@ -201,7 +201,7 @@ export const isOwnUserProfile = (): boolean => getCleanPathname() === getUsernam
201
201
// If there's a Report Abuse link, we're not part of the org
202
202
export const isOwnOrganizationProfile = ( ) : boolean => isOrganizationProfile ( ) && ! exists ( '[href*="contact/report-abuse?report="]' ) ;
203
203
204
- export const isProject = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p r o j e c t s \/ \d + / . test ( getRepo ( url ) ?. path ! ) ;
204
+ export const isProject = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p r o j e c t s \/ \d + / . test ( getRepo ( url ) ?. path ) ;
205
205
addTests ( 'isProject' , [
206
206
'https://github.com/sindresorhus/refined-github/projects/3' ,
207
207
] ) ;
@@ -211,7 +211,7 @@ addTests('isProjects', [
211
211
'https://github.com/sindresorhus/refined-github/projects' ,
212
212
] ) ;
213
213
214
- 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 ! ) ;
214
+ 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 ) ;
215
215
addTests ( 'isDiscussion' , [
216
216
'https://github.com/tophf/mpiv/discussions/50' ,
217
217
'https://github.com/orgs/community/discussions/11202' ,
@@ -229,14 +229,14 @@ addTests('isDiscussionList', [
229
229
'https://github.com/orgs/community/discussions' ,
230
230
] ) ;
231
231
232
- export const isPR = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + / . test ( getRepo ( url ) ?. path ! ) && ! isPRConflicts ( url ) ;
232
+ export const isPR = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + / . test ( getRepo ( url ) ?. path ) && ! isPRConflicts ( url ) ;
233
233
addTests ( 'isPR' , [
234
234
'isPRFiles' ,
235
235
'isPRCommitList' ,
236
236
'https://github.com/sindresorhus/refined-github/pull/148' ,
237
237
] ) ;
238
238
239
- export const isPRConflicts = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ c o n f l i c t s / . test ( getRepo ( url ) ?. path ! ) ;
239
+ export const isPRConflicts = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ c o n f l i c t s / . test ( getRepo ( url ) ?. path ) ;
240
240
addTests ( 'isPRConflicts' , [
241
241
'https://github.com/sindresorhus/refined-github/pull/148/conflicts' ,
242
242
] ) ;
@@ -252,7 +252,7 @@ addTests('isPRList', [
252
252
'https://github.com/sindresorhus/refined-github/pulls?q=is%3Apr+is%3Aclosed' ,
253
253
] ) ;
254
254
255
- export const isPRCommit = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ c o m m i t s \/ [ \d a - f ] { 5 , 40 } $ / . test ( getRepo ( url ) ?. path ! ) ;
255
+ export const isPRCommit = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ c o m m i t s \/ [ \d a - f ] { 5 , 40 } $ / . test ( getRepo ( url ) ?. path ) ;
256
256
addTests ( 'isPRCommit' , [
257
257
'https://github.com/sindresorhus/refined-github/pull/148/commits/0019603b83bd97c2f7ef240969f49e6126c5ec85' ,
258
258
'https://github.com/sindresorhus/refined-github/pull/148/commits/00196' ,
@@ -261,17 +261,17 @@ addTests('isPRCommit', [
261
261
export const isPRCommit404 = ( ) : boolean => isPRCommit ( ) && document . title . startsWith ( 'Commit range not found · Pull Request' ) ;
262
262
export const isPRFile404 = ( ) : boolean => isPRFiles ( ) && document . title . startsWith ( 'Commit range not found · Pull Request' ) ;
263
263
264
- export const isPRConversation = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + $ / . test ( getRepo ( url ) ?. path ! ) ;
264
+ export const isPRConversation = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + $ / . test ( getRepo ( url ) ?. path ) ;
265
265
addTests ( 'isPRConversation' , [
266
266
'https://github.com/sindresorhus/refined-github/pull/148' ,
267
267
] ) ;
268
268
269
- export const isPRCommitList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ c o m m i t s $ / . test ( getRepo ( url ) ?. path ! ) ;
269
+ export const isPRCommitList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ c o m m i t s $ / . test ( getRepo ( url ) ?. path ) ;
270
270
addTests ( 'isPRCommitList' , [
271
271
'https://github.com/sindresorhus/refined-github/pull/148/commits' ,
272
272
] ) ;
273
273
274
- export const isPRFiles = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ f i l e s / . test ( getRepo ( url ) ?. path ! ) || isPRCommit ( url ) ;
274
+ export const isPRFiles = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ f i l e s / . test ( getRepo ( url ) ?. path ) || isPRCommit ( url ) ;
275
275
addTests ( 'isPRFiles' , [
276
276
'isPRCommit' , // File contents but lacks "Viewed" checkbox, has commit information
277
277
'https://github.com/sindresorhus/refined-github/pull/148/files' ,
@@ -378,7 +378,7 @@ export const isArchivedRepo = (): boolean => Boolean(isRepo() && $('main > .flas
378
378
379
379
export const isBlank = ( ) : boolean => exists ( 'main .blankslate:not([hidden] .blankslate)' ) ;
380
380
381
- export const isRepoTaxonomyIssueOrPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ l a b e l s \/ .+ | ^ m i l e s t o n e s \/ \d + (? ! \/ e d i t ) / . test ( getRepo ( url ) ?. path ! ) ;
381
+ export const isRepoTaxonomyIssueOrPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ l a b e l s \/ .+ | ^ m i l e s t o n e s \/ \d + (? ! \/ e d i t ) / . test ( getRepo ( url ) ?. path ) ;
382
382
addTests ( 'isRepoTaxonomyIssueOrPRList' , [
383
383
'https://github.com/sindresorhus/refined-github/labels/bug' ,
384
384
'https://github.com/sindresorhus/refined-github/labels/implemented%20by%20github' ,
@@ -402,7 +402,7 @@ addTests('isRepoPRList', [
402
402
403
403
export const isRepoIssueList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean =>
404
404
// `issues/fregante` is a list but `issues/1`, `issues/new`, `issues/new/choose`, `issues/templates/edit` aren’t
405
- / ^ l a b e l s \/ | ^ i s s u e s (? ! \/ ( \d + | n e w | t e m p l a t e s ) ( $ | \/ ) ) / . test ( getRepo ( url ) ?. path ! ) ;
405
+ / ^ l a b e l s \/ | ^ i s s u e s (? ! \/ ( \d + | n e w | t e m p l a t e s ) ( $ | \/ ) ) / . test ( getRepo ( url ) ?. path ) ;
406
406
addTests ( 'isRepoIssueList' , [
407
407
'http://github.com/sindresorhus/ava/issues' ,
408
408
'https://github.com/sindresorhus/refined-github/issues' ,
@@ -513,7 +513,7 @@ addTests('isRepoWiki', [
513
513
'https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d' ,
514
514
] ) ;
515
515
516
- export const isSingleCommit = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ c o m m i t \/ [ \d a - f ] { 5 , 40 } $ / . test ( getRepo ( url ) ?. path ! ) ;
516
+ export const isSingleCommit = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ c o m m i t \/ [ \d a - f ] { 5 , 40 } $ / . test ( getRepo ( url ) ?. path ) ;
517
517
addTests ( 'isSingleCommit' , [
518
518
'https://github.com/sindresorhus/refined-github/commit/5b614b9035f2035b839f48b4db7bd5c3298d526f' ,
519
519
'https://github.com/sindresorhus/refined-github/commit/5b614' ,
@@ -549,14 +549,14 @@ addTests('isRepoNetworkGraph', [
549
549
550
550
export const isForkedRepo = ( ) : boolean => exists ( 'meta[name="octolytics-dimension-repository_is_fork"][content="true"]' ) ;
551
551
552
- export const isSingleGist = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ [ ^ / ] + \/ [ \d a - f ] { 20 , 32 } ( \/ [ \d a - f ] { 40 } ) ? $ / . test ( getCleanGistPathname ( url ) ! ) ;
552
+ export const isSingleGist = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ [ ^ / ] + \/ [ \d a - f ] { 20 , 32 } ( \/ [ \d a - f ] { 40 } ) ? $ / . test ( getCleanGistPathname ( url ) ) ;
553
553
addTests ( 'isSingleGist' , [
554
554
'https://gist.github.com/fregante/2205329b71218fa2c1d3' ,
555
555
'https://gist.github.com/fregante/2205329b71218fa2c1d3/d1ebf7d9cfaba4d4596d2ea9174e202479a5f9ad' ,
556
556
'https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064' ,
557
557
] ) ;
558
558
559
- export const isGistRevision = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ [ ^ / ] + \/ [ \d a - f ] { 20 , 32 } \/ r e v i s i o n s $ / . test ( getCleanGistPathname ( url ) ! ) ;
559
+ export const isGistRevision = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ [ ^ / ] + \/ [ \d a - f ] { 20 , 32 } \/ r e v i s i o n s $ / . test ( getCleanGistPathname ( url ) ) ;
560
560
addTests ( 'isGistRevision' , [
561
561
'https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions' ,
562
562
] ) ;
@@ -713,7 +713,7 @@ addTests('isActionJobRun', [
713
713
'https://github.com/refined-github/github-url-detection/runs/1224552520?check_suite_focus=true' ,
714
714
] ) ;
715
715
716
- export const isActionRun = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ ( a c t i o n s \/ ) ? r u n s / . test ( getRepo ( url ) ?. path ! ) ;
716
+ export const isActionRun = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ ( a c t i o n s \/ ) ? r u n s / . test ( getRepo ( url ) ?. path ) ;
717
717
addTests ( 'isActionRun' , [
718
718
'https://github.com/sindresorhus/refined-github/runs/639481849' ,
719
719
'https://github.com/refined-github/github-url-detection/runs/1224552520?check_suite_focus=true' ,
@@ -725,7 +725,7 @@ addTests('isNewAction', [
725
725
'https://github.com/sindresorhus/refined-github/actions/new' ,
726
726
] ) ;
727
727
728
- export const isRepositoryActions = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ a c t i o n s ( \/ w o r k f l o w s \/ .+ \. y a ? m l ) ? $ / . test ( getRepo ( url ) ?. path ! ) ;
728
+ export const isRepositoryActions = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ a c t i o n s ( \/ w o r k f l o w s \/ .+ \. y a ? m l ) ? $ / . test ( getRepo ( url ) ?. path ) ;
729
729
addTests ( 'isRepositoryActions' , [
730
730
'https://github.com/refined-github/github-url-detection/actions' ,
731
731
'https://github.com/refined-github/github-url-detection/actions/workflows/demo.yml' ,
@@ -749,7 +749,7 @@ addTests('isNewRepoTemplate', [
749
749
] ) ;
750
750
751
751
/** Get the logged-in user’s username */
752
- const getUsername = ( ) : string | undefined => $ ( 'meta[name="user-login"]' ) ?. getAttribute ( 'content' ) ! ;
752
+ const getUsername = ( ) : string | undefined => $ ( 'meta[name="user-login"]' ) ?. getAttribute ( 'content' ) ?? undefined ;
753
753
754
754
/** Drop all duplicate slashes */
755
755
const getCleanPathname = ( url : URL | HTMLAnchorElement | Location = location ) : string => url . pathname . replaceAll ( / \/ + / g, '/' ) . slice ( 1 , url . pathname . endsWith ( '/' ) ? - 1 : undefined ) ;
0 commit comments