Skip to content

Commit

Permalink
Rename getUsername to getLoggedInUser
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Aug 21, 2024
1 parent 968a6cb commit 9b197f6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ TEST: addTests('isTeamDiscussion', [
'https://github.com/orgs/refined-github/teams/core-team',
]);

export const isOwnUserProfile = (): boolean => getCleanPathname() === getUsername();
export const isOwnUserProfile = (): boolean => getCleanPathname() === getLoggedInUser();

// If there's a Report Abuse link, we're not part of the org
export const isOwnOrganizationProfile = (): boolean => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
Expand Down Expand Up @@ -749,7 +749,7 @@ TEST: addTests('isNewRepoTemplate', [
]);

/** Get the logged-in user’s username */
const getUsername = (): string | undefined => $('meta[name="user-login"]')?.getAttribute('content') ?? undefined;
const getLoggedInUser = (): string | undefined => $('meta[name="user-login"]')?.getAttribute('content') ?? undefined;

/** Drop all duplicate slashes */
const getCleanPathname = (url: URL | HTMLAnchorElement | Location = location): string => url.pathname.replaceAll(/\/+/g, '/').slice(1, url.pathname.endsWith('/') ? -1 : undefined);
Expand Down Expand Up @@ -825,7 +825,9 @@ const getRepo = (url?: URL | HTMLAnchorElement | Location | string): RepositoryI

export const utils = {
getOrg,
getUsername,
/** @deprecated Use `getLoggedInUser` */
getUsername: getLoggedInUser,
getLoggedInUser,
getCleanPathname,
getCleanGistPathname,
getRepositoryInfo: getRepo,
Expand Down

0 comments on commit 9b197f6

Please sign in to comment.