diff options
Diffstat (limited to 'source/github-helpers/api.ts')
-rw-r--r-- | source/github-helpers/api.ts | 16 |
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; } |