Skip to content

Commit f56e530

Browse files
committed
Add JSDoc to utils (#5)
1 parent 348058f commit f56e530

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,15 +428,17 @@ export const canUserEditRepo = (): boolean => isRepo() && exists('.reponav-item[
428428
/** @deprecated use canUserEditRepo instead */
429429
export const isRepoWithAccess = canUserEditRepo;
430430

431+
/** Get the logged-in user’s username */
431432
const 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 */
434435
const 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+
*/
440442
const getRepoPath = (url: URL | Location = location): string | undefined => {
441443
if (isRepo(url)) {
442444
return getCleanPathname(url).split('/').slice(2).join('/');

0 commit comments

Comments
 (0)