@@ -424,9 +424,16 @@ TEST: addTests('isRepo', [
424424export const hasRepoHeader = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isRepo ( url ) && ! isRepoSearch ( url ) ;
425425TEST: addTests ( 'hasRepoHeader' , combinedTestOnly ) ;
426426
427- // On empty repos, there's only isRepoHome; this element is found in `<head>`
428- export const isEmptyRepoRoot = ( ) : boolean => isRepoHome ( ) && ! exists ( 'link[rel="canonical"]' ) ;
427+ export const isEmptyRepoRoot = ( ) : boolean => isRepoHome ( ) && exists ( [
428+ // If you don't have write access
429+ '.blankslate-icon' ,
430+ // If you have write access
431+ '#empty-setup-clone-url' ,
432+ ] . join ( ',' ) ) ;
429433
434+ /**
435+ * @deprecated Doesn't work anymore. Use `isEmptyRepoRoot` or API instead.
436+ */
430437export const isEmptyRepo = ( ) : boolean => exists ( '[aria-label="Cannot fork because repository is empty."]' ) ;
431438
432439export const isPublicRepo = ( ) : boolean => exists ( 'meta[name="octolytics-dimension-repository_public"][content="true"]' ) ;
@@ -885,7 +892,14 @@ TEST: addTests('isRepositoryActions', [
885892
886893export const isUserTheOrganizationOwner = ( ) : boolean => isOrganizationProfile ( ) && exists ( '[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]' ) ;
887894
888- export const canUserAdminRepo = ( ) : boolean => isRepo ( ) && exists ( '.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]' ) ;
895+ export const canUserAdminRepo = ( ) : boolean => {
896+ const repo = getRepo ( ) ;
897+ return Boolean ( repo && exists ( `:is(${ [
898+ '.GlobalNav' ,
899+ // Remove after June 2026
900+ '.js-repo-nav' ,
901+ ] . join ( ',' ) } ) a[href="/${ repo . nameWithOwner } /settings"]`) ) ;
902+ } ;
889903
890904export const isNewRepo = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => ! isGist ( url ) && ( url . pathname === '/new' || / ^ o r g a n i z a t i o n s \/ [ ^ / ] + \/ r e p o s i t o r i e s \/ n e w $ / . test ( getCleanPathname ( url ) ) ) ;
891905TEST: addTests ( 'isNewRepo' , [
0 commit comments