File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -428,15 +428,17 @@ export const canUserEditRepo = (): boolean => isRepo() && exists('.reponav-item[
428
428
/** @deprecated use canUserEditRepo instead */
429
429
export const isRepoWithAccess = canUserEditRepo ;
430
430
431
+ /** Get the logged-in user’s username */
431
432
const getUsername = ( ) => document . querySelector ( 'meta[name="user-login"]' ) ! . getAttribute ( 'content' ) ! ;
432
433
433
- // Drops leading and trailing slash to avoid /\/?/ everywhere
434
+ /** Drop leading and trailing slashes */
434
435
const getCleanPathname = ( url : URL | Location = location ) : string => url . pathname . replace ( / ^ \/ | \/ $ / g, '' ) ;
435
436
436
- // Parses a repo's subpage, e.g.
437
- // '/user/repo/issues/' -> 'issues'
438
- // '/user/repo/' -> ''
439
- // returns undefined if the path is not a repo
437
+ /** Parses a repo's subpage
438
+ @example '/user/repo/issues/' -> 'issues'
439
+ @example '/user/repo/' -> ''
440
+ @exampke '/settings/token/' -> undefined
441
+ */
440
442
const getRepoPath = ( url : URL | Location = location ) : string | undefined => {
441
443
if ( isRepo ( url ) ) {
442
444
return getCleanPathname ( url ) . split ( '/' ) . slice ( 2 ) . join ( '/' ) ;
You can’t perform that action at this time.
0 commit comments