mirror of
https://github.com/desktop/desktop
synced 2024-09-17 23:21:55 +00:00
Add support private repo images
This commit is contained in:
parent
9120bdf22c
commit
86e79e8ab0
|
@ -1,9 +1,19 @@
|
|||
import { EndpointToken } from '../lib/endpoint-token'
|
||||
import { OrderedWebRequest } from './ordered-webrequest'
|
||||
|
||||
function isEnterpriseAvatarPath(pathname: string) {
|
||||
return pathname.startsWith('/api/v3/enterprise/avatars/')
|
||||
}
|
||||
|
||||
function isGitHubRepoAssetPath(pathname: string) {
|
||||
// Matches paths like: /repo/owner/assets/userID/guid
|
||||
return /^\/[^/]+\/[^/]+\/assets\/[^/]+\/[^/]+\/?$/.test(pathname)
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a web request filter which adds the Authorization header for
|
||||
* unauthenticated requests to the GHES/GHAE private avatars API.
|
||||
* unauthenticated requests to the GHES/GHAE private avatars API, and for private
|
||||
* repo assets.
|
||||
*
|
||||
* Returns a method that can be used to update the list of signed-in accounts
|
||||
* which is used to resolve which token to use.
|
||||
|
@ -17,7 +27,10 @@ export function installAuthenticatedAvatarFilter(
|
|||
const { origin, pathname } = new URL(details.url)
|
||||
const token = originTokens.get(origin)
|
||||
|
||||
if (token && pathname.startsWith('/api/v3/enterprise/avatars/')) {
|
||||
if (
|
||||
token &&
|
||||
(isEnterpriseAvatarPath(pathname) || isGitHubRepoAssetPath(pathname))
|
||||
) {
|
||||
return {
|
||||
requestHeaders: {
|
||||
...details.requestHeaders,
|
||||
|
|
Loading…
Reference in a new issue