@@ -812,6 +812,34 @@ TEST: addTests('isRepositoryActions', [
812812 'https://github.com/refined-github/github-url-detection/actions/workflows/esm-lint.yml' ,
813813] ) ;
814814
815+ export const isStars = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => {
816+ const patharr = getCleanPathname ( url ) . split ( '/' ) , [ stars , user , lists , ...extra ] = patharr ;
817+ return stars === 'stars'
818+ && ( [ 1 , 2 , 4 ] . includes ( patharr . length )
819+ || lists === 'lists' && extra . length !== 0 ) ;
820+ } ;
821+ TEST: addTests ( 'isStars' , [
822+ 'https://github.com/stars' ,
823+ 'https://github.com/stars/lstn' ,
824+ 'https://github.com/stars/lstn/repositories' ,
825+ 'https://github.com/stars/lstn/lists/test'
826+ ] ) ;
827+
828+ export const isOwnStars = ( url : URL | HTMLAnchorElement | Location = location ) : boolean =>
829+ isStars ( url )
830+ && [ [ 'stars' ] , [ 'stars' , getLoggedInUser ( ) ] ] . some (
831+ ( needle => arr => arr . length === needle . length
832+ && arr . every ( ( v , i ) => v === needle [ i ] ) ) ( getCleanPathname ( url ) . split ( '/' ) . slice ( 0 , 2 ) )
833+ ) ;
834+
835+ export const isStarsList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isStars ( url ) && getCleanPathname ( url ) . split ( '/' ) [ 2 ] === 'lists' ;
836+ TEST: addTests ( 'isStarsList' , [
837+ 'https://github.com/stars/lstn/lists/test'
838+ ] ) ;
839+
840+ export const isOwnStarsList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isOwnStars ( url ) && getCleanPathname ( url ) . split ( '/' ) [ 2 ] === 'lists' ;
841+
842+
815843export const isUserTheOrganizationOwner = ( ) : boolean => isOrganizationProfile ( ) && exists ( '[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]' ) ;
816844
817845export const canUserAdminRepo = ( ) : boolean => isRepo ( ) && exists ( '.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]' ) ;
0 commit comments