summaryrefslogtreecommitdiff
path: root/source/libs/utils.ts
diff options
context:
space:
mode:
authorGravatar Jeroen van Warmerdam <jeronevw@hotmail.com> 2019-06-04 20:29:24 +0200
committerGravatar Federico Brigante <github@bfred.it> 2019-06-05 02:29:24 +0800
commit0a6b6b4613a5caa2e21d46d11ef686b13d09504c (patch)
tree99f589c0ad78880db32f16da4bfd66d8cb159451 /source/libs/utils.ts
parented0ace7f1f1fa9b49dbc5733a9606e42031b3188 (diff)
downloadrefined-github-0a6b6b4613a5caa2e21d46d11ef686b13d09504c.tar.gz
refined-github-0a6b6b4613a5caa2e21d46d11ef686b13d09504c.tar.zst
refined-github-0a6b6b4613a5caa2e21d46d11ef686b13d09504c.zip
Link to current branch in More's Compare and Commits links (#2102)
Diffstat (limited to 'source/libs/utils.ts')
-rw-r--r--source/libs/utils.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/libs/utils.ts b/source/libs/utils.ts
index a7ddf562..f3a7b2c8 100644
--- a/source/libs/utils.ts
+++ b/source/libs/utils.ts
@@ -40,6 +40,15 @@ export const getOwnerAndRepo = (): {
return {ownerName, repoName};
};
+export const getRef = (): string | undefined => {
+ const pathnameParts = location.pathname.split('/');
+ if (['commits', 'blob', 'tree', 'blame'].includes(pathnameParts[3])) {
+ return pathnameParts[4];
+ }
+
+ return undefined;
+};
+
export const parseTag = (tag: string): {version: string; namespace: string} => {
const [, namespace = '', version = ''] = tag.match(/(?:(.*)@)?([^@]+)/) || [];
return {namespace, version};