@@ -330,7 +330,7 @@ collect.set('isRepoRoot', [
330
330
331
331
// This can't use `getRepoPath` to avoid infinite recursion.
332
332
// `getRepoPath` depends on `isRepo` and `isRepo` depends on `isRepoSearch`
333
- export const isRepoSearch = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => url . pathname . slice ( 1 ) . split ( '/' ) [ 2 ] === 'search' ;
333
+ export const isRepoSearch = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => url . pathname . split ( '/' ) [ 3 ] === 'search' ;
334
334
collect . set ( 'isRepoSearch' , [
335
335
'https://github.com/sindresorhus/refined-github/search?q=diff' ,
336
336
'https://github.com/sindresorhus/refined-github/search?q=diff&unscoped_q=diff&type=Issues' ,
@@ -491,7 +491,7 @@ collect.set('isNewRepo', [
491
491
const getUsername = ( ) => document . querySelector ( 'meta[name="user-login"]' ) ! . getAttribute ( 'content' ) ! ;
492
492
493
493
/** Drop leading and trailing slashes */
494
- const getCleanPathname = ( url : URL | HTMLAnchorElement | Location = location ) : string => url . pathname . replace ( / ^ \/ | \/ $ / g , '' ) ;
494
+ const getCleanPathname = ( url : URL | HTMLAnchorElement | Location = location ) : string => url . pathname . slice ( 1 , url . pathname . endsWith ( '/' ) ? - 1 : undefined ) ;
495
495
496
496
/** Parses a repo's subpage
497
497
@example '/user/repo/issues/' -> 'issues'
@@ -507,7 +507,7 @@ const getRepoPath = (url: URL | HTMLAnchorElement | Location = location): string
507
507
} ;
508
508
509
509
/** Get the 'user/repo' part from an URL. Tries using the canonical URL to avoid capitalization errors in the `location` URL */
510
- const getRepoURL = ( url ?: URL | Location ) : string => {
510
+ const getRepoURL = ( url ?: URL | HTMLAnchorElement | Location ) : string => {
511
511
if ( ! url ) {
512
512
const canonical = document . querySelector < HTMLMetaElement > ( '[property="og:url"]' ) ; // `rel=canonical` doesn't appear on every page
513
513
url = canonical ? new URL ( canonical . content , location . origin ) : location ;
0 commit comments