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[
428428/** @deprecated use canUserEditRepo instead */
429429export const isRepoWithAccess = canUserEditRepo ;
430430
431+ /** Get the logged-in user’s username */
431432const getUsername = ( ) => document . querySelector ( 'meta[name="user-login"]' ) ! . getAttribute ( 'content' ) ! ;
432433
433- // Drops leading and trailing slash to avoid /\/?/ everywhere
434+ /** Drop leading and trailing slashes */
434435const getCleanPathname = ( url : URL | Location = location ) : string => url . pathname . replace ( / ^ \/ | \/ $ / g, '' ) ;
435436
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+ */
440442const getRepoPath = ( url : URL | Location = location ) : string | undefined => {
441443 if ( isRepo ( url ) ) {
442444 return getCleanPathname ( url ) . split ( '/' ) . slice ( 2 ) . join ( '/' ) ;
You can’t perform that action at this time.
0 commit comments