summaryrefslogtreecommitdiff
path: root/source/github-helpers/api.ts
diff options
context:
space:
mode:
authorGravatar yakov116 <16872793+yakov116@users.noreply.github.com> 2020-10-26 08:40:40 -0400
committerGravatar GitHub <noreply@github.com> 2020-10-26 08:40:40 -0400
commitde5c0b49d754a8996f20742bb19b1b33d175969b (patch)
treeeb75f4499680ca503c4828bfb895643644a7e271 /source/github-helpers/api.ts
parenta38bf75cea20ed97314ed949ee5b3c63faf8962b (diff)
downloadrefined-github-de5c0b49d754a8996f20742bb19b1b33d175969b.tar.gz
refined-github-de5c0b49d754a8996f20742bb19b1b33d175969b.tar.zst
refined-github-de5c0b49d754a8996f20742bb19b1b33d175969b.zip
Lint (#3684)
Co-authored-by: Federico <me@fregante.com>
Diffstat (limited to 'source/github-helpers/api.ts')
-rw-r--r--source/github-helpers/api.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/github-helpers/api.ts b/source/github-helpers/api.ts
index d99f3de4..575c793e 100644
--- a/source/github-helpers/api.ts
+++ b/source/github-helpers/api.ts
@@ -6,7 +6,8 @@ next to the name of the feature that caused them.
Usage:
import * as api from '../github-helpers/api';
-const user = await api.v3(`users/${username}`);
+const user = await api.v3(`/users/${username}`);
+const repositoryCommits = await api.v3('commits'); // Without a leading `/`, this is equivalent to `/repo/$current-repository/commits`
const data = await api.v4('{user(login: "user") {name}}');
Returns:
@@ -29,6 +30,7 @@ import * as pageDetect from 'github-url-detection';
import {JsonObject, AsyncReturnType} from 'type-fest';
import optionsStorage from '../options-storage';
+import {getRepoURL} from '.';
interface JsonError {
message: string;
@@ -102,8 +104,8 @@ export const v3 = mem(async (
const {ignoreHTTPStatus, method, body, headers, json} = {...v3defaults, ...options};
const {personalToken} = await settings;
- if (query.startsWith('/')) {
- throw new TypeError('The query parameter must not start with a slash.');
+ if (!query.startsWith('https')) {
+ query = query.startsWith('/') ? query.slice(1) : 'repos/' + getRepoURL() + '/' + query;
}
const url = new URL(query, api3);