summaryrefslogtreecommitdiff
path: root/source/github-helpers/github-url.ts
diff options
context:
space:
mode:
Diffstat (limited to 'source/github-helpers/github-url.ts')
-rw-r--r--source/github-helpers/github-url.ts5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/github-helpers/github-url.ts b/source/github-helpers/github-url.ts
index 4f7db9b9..785a86c5 100644
--- a/source/github-helpers/github-url.ts
+++ b/source/github-helpers/github-url.ts
@@ -35,6 +35,7 @@ export default class GitHubURL {
private disambiguateReference(ambiguousReference: string[]): {branch: string; filePath: string} {
const branch = ambiguousReference[0];
+ // History pages might use search parameters
const filePathFromSearch = this.searchParams.getAll('path[]').join('/');
if (filePathFromSearch) {
this.searchParams.delete('path[]');
@@ -44,6 +45,10 @@ export default class GitHubURL {
const filePath = ambiguousReference.slice(1).join('/');
const currentBranch = getCurrentBranch();
+ if (!currentBranch) {
+ throw new Error('GitHubURL can only be used on pages with a branch/reference.');
+ }
+
const currentBranchSections = currentBranch.split('/');
if (
ambiguousReference.length === 1 || // Ref has no slashes