summaryrefslogtreecommitdiff
path: root/source/github-helpers/index.ts
diff options
context:
space:
mode:
authorGravatar Fregante <opensource@bfred.it> 2020-06-16 19:56:43 +0200
committerGravatar GitHub <noreply@github.com> 2020-06-16 19:56:43 +0200
commita918f9a3eb6827dd67efdd1bcf362df2e7152406 (patch)
tree4aeb0966e89ed9a641f519f8934a959a868a8823 /source/github-helpers/index.ts
parent1d003c988da53f575b0285f8366ada9b80b76510 (diff)
downloadrefined-github-a918f9a3eb6827dd67efdd1bcf362df2e7152406.tar.gz
refined-github-a918f9a3eb6827dd67efdd1bcf362df2e7152406.tar.zst
refined-github-a918f9a3eb6827dd67efdd1bcf362df2e7152406.zip
Meta: Minor improvements and lint (#3231)
Diffstat (limited to 'source/github-helpers/index.ts')
-rw-r--r--source/github-helpers/index.ts21
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} => {