summaryrefslogtreecommitdiff
path: root/source/github-helpers/api.ts
diff options
context:
space:
mode:
authorGravatar yakov116 <16872793+yakov116@users.noreply.github.com> 2020-07-16 05:07:16 -0400
committerGravatar GitHub <noreply@github.com> 2020-07-16 11:07:16 +0200
commit86529e79015ea54b2eda9f06a1aca692acf7baea (patch)
tree8bf0888f7de4acc24f39f05d1a0f4a08805a7b28 /source/github-helpers/api.ts
parent9965efc5477540ab8d6b57149b9375efa6746ead (diff)
downloadrefined-github-86529e79015ea54b2eda9f06a1aca692acf7baea.tar.gz
refined-github-86529e79015ea54b2eda9f06a1aca692acf7baea.tar.zst
refined-github-86529e79015ea54b2eda9f06a1aca692acf7baea.zip
Lint (#3341)
* use pageDetect for `find-file-buffer` * Update source/features/file-finder-buffer.tsx Co-authored-by: Fregante <opensource@bfred.it> * Update dep * Inline init `format-conversation-titles` * `init: () =>` => `init()` * remove ajax false from `align-issue-labels` * Move loose parse int to its own file * Fix api on gist pages * Remove duplicate undefined * lint * Sort from * limit `remove-diff-signs` to `has-code` * Sort from * Restore package.json * Restore package-lock.json * Use `isEnterprise()` * use ObserveElement for `linkify-user-location` * Restore linkify-user-location.tsx * Update `github-url-detection` Co-authored-by: Fregante <opensource@bfred.it>
Diffstat (limited to 'source/github-helpers/api.ts')
-rw-r--r--source/github-helpers/api.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/source/github-helpers/api.ts b/source/github-helpers/api.ts
index 98849238..1a7d8d62 100644
--- a/source/github-helpers/api.ts
+++ b/source/github-helpers/api.ts
@@ -25,6 +25,7 @@ so the call will not throw an error but it will return as usual.
*/
import mem from 'mem';
+import * as pageDetect from 'github-url-detection';
import {JsonObject, AsyncReturnType} from 'type-fest';
import optionsStorage from '../options-storage';
@@ -55,17 +56,18 @@ export class RefinedGitHubAPIError extends Error {
const settings = optionsStorage.getAll();
-const api3 = location.hostname === 'github.com' ?
- 'https://api.github.com/' :
- `${location.origin}/api/v3/`;
-const api4 = location.hostname === 'github.com' ?
- 'https://api.github.com/graphql' :
- `${location.origin}/api/graphql`;
+const api3 = pageDetect.isEnterprise() ?
+ `${location.origin}/api/v3/` :
+ 'https://api.github.com/';
+
+const api4 = pageDetect.isEnterprise() ?
+ `${location.origin}/api/graphql` :
+ 'https://api.github.com/graphql';
interface GHRestApiOptions {
ignoreHTTPStatus?: boolean;
method?: 'GET' | 'POST' | 'PUT';
- body?: undefined | JsonObject;
+ body?: JsonObject;
headers?: HeadersInit;
json?: boolean;
}