@@ -813,35 +813,36 @@ TEST: addTests('isRepositoryActions', [
813813] ) ;
814814
815815const isStars = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => {
816- const patharr = getCleanPathname ( url ) . split ( '/' ) , [ stars , user , subpath , ...extra ] = patharr ;
817- return stars === 'stars'
818- && ( [ 1 , 2 , 4 ] . includes ( patharr . length )
819- || subpath === 'lists' && patharr . length !== 3
820- || [ 'repositories' , 'topics' ] . includes ( subpath ) && patharr . length == 3 ) ;
821- }
816+ const patharr = getCleanPathname ( url ) . split ( '/' ) ;
817+ const [ stars , user , subpath , ...extra ] = patharr ;
818+ return stars === 'stars'
819+ && ( [ 1 , 2 , 4 ] . includes ( patharr . length )
820+ || ( subpath === 'lists' && patharr . length !== 3 )
821+ || ( [ 'repositories' , 'topics' ] . includes ( subpath ) && patharr . length === 3 ) ) ;
822+ } ;
823+
822824TEST: addTests ( 'isStars' , [
823825 'https://github.com/stars' ,
824826 'https://github.com/stars/lstn' ,
825827 'https://github.com/stars/lstn/repositories' ,
826828 'https://github.com/stars/lstn/topics' ,
827- 'https://github.com/stars/lstn/lists/test'
829+ 'https://github.com/stars/lstn/lists/test' ,
828830] ) ;
829831
830832export const isOwnStars = ( url : URL | HTMLAnchorElement | Location = location ) : boolean =>
831- isStars ( url )
832- && [ [ 'stars' ] , [ 'stars' , getLoggedInUser ( ) ] ] . some (
833- ( needle => arr => arr . length === needle . length
834- && arr . every ( ( v , i ) => v === needle [ i ] ) ) ( getCleanPathname ( url ) . split ( '/' ) . slice ( 0 , 2 ) )
835- ) ;
833+ isStars ( url )
834+ && [ [ 'stars' ] , [ 'stars' , getLoggedInUser ( ) ] ] . some (
835+ ( needle => pathArray => pathArray . length === needle . length
836+ && pathArray . every ( ( v , i ) => v === needle [ i ] ) ) ( getCleanPathname ( url ) . split ( '/' ) . slice ( 0 , 2 ) ) ,
837+ ) ;
836838
837839export const isStarsList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isStars ( url ) && getCleanPathname ( url ) . split ( '/' ) [ 2 ] === 'lists' ;
838840TEST: addTests ( 'isStarsList' , [
839- 'https://github.com/stars/lstn/lists/test'
841+ 'https://github.com/stars/lstn/lists/test' ,
840842] ) ;
841843
842844export const isOwnStarsList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isOwnStars ( url ) && getCleanPathname ( url ) . split ( '/' ) [ 2 ] === 'lists' ;
843845
844-
845846export const isUserTheOrganizationOwner = ( ) : boolean => isOrganizationProfile ( ) && exists ( '[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]' ) ;
846847
847848export const canUserAdminRepo = ( ) : boolean => isRepo ( ) && exists ( '.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]' ) ;
0 commit comments