Skip to content

Commit 026e711

Browse files
authored
Merge pull request desktop#19009 from desktop/treat-gists-as-generic
Treat gist as generic for credential helper
2 parents 7a7d602 + d5f1aaa commit 026e711

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

app/src/lib/endpoint-capabilities.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export const isDotCom = (ep: string) => {
5353
return hostname === 'api.github.com' || hostname === 'github.com'
5454
}
5555

56+
export const isGist = (ep: string) => {
57+
const { hostname } = new URL(ep)
58+
return hostname === 'gist.github.com' || hostname === 'gist.ghe.io'
59+
}
60+
5661
/** Whether or not the given endpoint URI is under the ghe.com domain */
5762
export const isGHE = (ep: string) => new URL(ep).hostname.endsWith('.ghe.com')
5863

app/src/lib/trampoline/trampoline-credential-helper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
import { urlWithoutCredentials } from './url-without-credentials'
2828
import { trampolineUIHelper as ui } from './trampoline-ui-helper'
2929
import { isGitHubHost } from '../api'
30-
import { isDotCom, isGHE } from '../endpoint-capabilities'
30+
import { isDotCom, isGHE, isGist } from '../endpoint-capabilities'
3131

3232
type Credential = Map<string, string>
3333
type Store = AccountsStore
@@ -140,6 +140,10 @@ const getEndpointKind = async (cred: Credential, store: Store) => {
140140
const credentialUrl = getCredentialUrl(cred)
141141
const endpoint = `${credentialUrl}`
142142

143+
if (isGist(endpoint)) {
144+
return 'generic'
145+
}
146+
143147
if (isDotCom(endpoint)) {
144148
return 'github.com'
145149
}

0 commit comments

Comments
 (0)