diff options
Diffstat (limited to 'source/libs/utils.ts')
-rw-r--r-- | source/libs/utils.ts | 9 |
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}; |