summaryrefslogtreecommitdiff
path: root/source/libs/utils.ts
diff options
context:
space:
mode:
authorGravatar Federico Brigante <github@bfred.it> 2019-12-16 00:47:51 +0700
committerGravatar GitHub <noreply@github.com> 2019-12-16 00:47:51 +0700
commit0b204c638f62116f3d34d64762966ad5683b194f (patch)
tree36ddff538ce853339f1ab395a299afb067bda253 /source/libs/utils.ts
parent5317a69cff0558709437dd0e1694cba5f07d467f (diff)
downloadrefined-github-0b204c638f62116f3d34d64762966ad5683b194f.tar.gz
refined-github-0b204c638f62116f3d34d64762966ad5683b194f.tar.zst
refined-github-0b204c638f62116f3d34d64762966ad5683b194f.zip
Small meta changes (#2626)
Diffstat (limited to 'source/libs/utils.ts')
-rw-r--r--source/libs/utils.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/libs/utils.ts b/source/libs/utils.ts
index b25a5b41..5eedbda0 100644
--- a/source/libs/utils.ts
+++ b/source/libs/utils.ts
@@ -4,7 +4,13 @@ import {isRepo, isPR, isIssue} from './page-detect';
export const getUsername = onetime(() => select('meta[name="user-login"]')!.getAttribute('content')!);
-export const getDiscussionNumber = (): string | false => (isPR() || isIssue()) && getCleanPathname().split('/')[3];
+export const getDiscussionNumber = (): string | undefined => {
+ if (isPR() || isIssue()) {
+ return getCleanPathname().split('/')[3];
+ }
+
+ return undefined;
+};
// Drops leading and trailing slash to avoid /\/?/ everywhere
export const getCleanPathname = (): string => location.pathname.replace(/^[/]|[/]$/g, '');
@@ -44,10 +50,12 @@ export const getCurrentBranch = (): string => {
.replace(/\.atom.*/, '');
};
+export const isFirefox = navigator.userAgent.includes('Firefox/');
+
export const getRepoURL = (): string => location.pathname.slice(1).split('/', 2).join('/');
export const getRepoGQL = (): string => {
const {ownerName, repoName} = getOwnerAndRepo();
- return `owner: "${ownerName}", name: "${repoName}"`;
+ return `owner: "${ownerName!}", name: "${repoName!}"`;
};
export const getOwnerAndRepo = (): {