summaryrefslogtreecommitdiff
path: root/source/github-helpers/github-url.ts
diff options
context:
space:
mode:
authorGravatar yakov116 <16872793+yakov116@users.noreply.github.com> 2020-10-18 01:06:29 -0400
committerGravatar GitHub <noreply@github.com> 2020-10-18 01:06:29 -0400
commit6a8fda98f257f2dff7fb039ca7ea94aec8208794 (patch)
tree69bae2a814accc591acd58f2976fa8d1e19dbc28 /source/github-helpers/github-url.ts
parentf395e1fe5925dc5f6e8892e71b8764f577528f22 (diff)
downloadrefined-github-6a8fda98f257f2dff7fb039ca7ea94aec8208794.tar.gz
refined-github-6a8fda98f257f2dff7fb039ca7ea94aec8208794.tar.zst
refined-github-6a8fda98f257f2dff7fb039ca7ea94aec8208794.zip
Avoid errors caused by `more-dropdown` on issues (#3653)
Co-authored-by: Federico <me@fregante.com> Co-authored-by: Laxman <bytemode@outlook.com>
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