diff options
Diffstat (limited to 'source/github-helpers/index.ts')
-rw-r--r-- | source/github-helpers/index.ts | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/source/github-helpers/index.ts b/source/github-helpers/index.ts index 8f9432f3..fc02b7a8 100644 --- a/source/github-helpers/index.ts +++ b/source/github-helpers/index.ts @@ -34,20 +34,21 @@ export const isFirefox = navigator.userAgent.includes('Firefox/'); export const getRepoURL = (): string => location.pathname.slice(1).split('/', 2).join('/').toLowerCase(); export const getRepoGQL = (): string => { - const {ownerName, repoName} = getOwnerAndRepo(); - return `owner: "${ownerName!}", name: "${repoName!}"`; + const {owner, name} = getCurrentRepository(); + return `owner: "${owner!}", name: "${name!}"`; }; -export const getOwnerAndRepo = (): { - ownerName?: string; - repoName?: string; -} => { - const [, ownerName, repoName] = location.pathname.split('/', 3); - return {ownerName, repoName}; -}; +export interface RepositoryInfo { + owner: string; + name: string; +} +export const getCurrentRepository = oneTime((): Partial<RepositoryInfo> => { + const [, owner, name] = location.pathname.split('/', 3); + return {owner, name}; +}); export function getForkedRepo(): string | undefined { - return select<HTMLAnchorElement>('.fork-flag a')?.pathname.slice(1); + return select<HTMLMetaElement>('[name="octolytics-dimension-repository_parent_nwo"]')?.content; } export const parseTag = (tag: string): {version: string; namespace: string} => { |