@@ -339,7 +339,6 @@ export const isRepo = (url: URL | HTMLAnchorElement | Location = location): bool
339
339
&& ! reservedNames . includes ( url . pathname . split ( '/' , 2 ) [ 1 ] ! )
340
340
&& ! isDashboard ( url )
341
341
&& ! isGist ( url )
342
- && ! isRepoSearch ( url )
343
342
&& ! isNewRepoTemplate ( url ) ;
344
343
addTests ( 'isRepo' , [
345
344
// Some of these are here simply as "gotchas" to other detections
@@ -353,6 +352,9 @@ addTests('isRepo', [
353
352
'https://github.com/sindresorhus/refined-github/issues/templates/edit' , // Gotcha for isRepoIssueList
354
353
] ) ;
355
354
355
+ export const hasRepoHeader = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isRepo ( url ) && ! isRepoSearch ( url ) ;
356
+ addTests ( 'hasRepoHeader' , combinedTestOnly ) ;
357
+
356
358
// On empty repos, there's only isRepoHome; this element is found in `<head>`
357
359
export const isEmptyRepoRoot = ( ) : boolean => isRepoHome ( ) && ! exists ( 'link[rel="canonical"]' ) ;
358
360
@@ -443,9 +445,7 @@ addTests('isRepoRoot', [
443
445
'https://github.com/sindresorhus/refined-github/tree/master?files=1' ,
444
446
] ) ;
445
447
446
- // This can't use `getRepositoryInfo().path` to avoid infinite recursion:
447
- // `getRepositoryInfo` depends on `isRepo` and `isRepo` depends on `isRepoSearch`
448
- export const isRepoSearch = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => url . pathname . split ( '/' ) [ 3 ] === 'search' ;
448
+ export const isRepoSearch = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => getRepo ( url ) ?. path === 'search' ; ;
449
449
addTests ( 'isRepoSearch' , [
450
450
'https://github.com/sindresorhus/refined-github/search?q=diff' ,
451
451
'https://github.com/sindresorhus/refined-github/search?q=diff&unscoped_q=diff&type=Issues' ,
@@ -643,7 +643,8 @@ export const hasRichTextEditor = (url: URL | HTMLAnchorElement | Location = loca
643
643
|| isDiscussion ( url ) ;
644
644
645
645
addTests ( 'hasCode' , combinedTestOnly ) ;
646
- export const hasCode = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => // Static code, not the editor
646
+ /** Static code, not the code editor */
647
+ export const hasCode = ( url : URL | HTMLAnchorElement | Location = location ) : boolean =>
647
648
hasComments ( url )
648
649
|| isRepoTree ( url ) // Readme files
649
650
|| isRepoSearch ( url )
@@ -655,7 +656,8 @@ export const hasCode = (url: URL | HTMLAnchorElement | Location = location): boo
655
656
|| isBlame ( url ) ;
656
657
657
658
addTests ( 'hasFiles' , combinedTestOnly ) ;
658
- export const hasFiles = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => // Has a list of files
659
+ /** Has a list of files */
660
+ export const hasFiles = ( url : URL | HTMLAnchorElement | Location = location ) : boolean =>
659
661
isCommit ( url )
660
662
|| isCompare ( url )
661
663
|| isPRFiles ( url ) ;
0 commit comments