Use exported isGHE

This commit is contained in:
Markus Olsson 2023-12-20 12:54:05 +01:00
parent 25020cfbdb
commit e927688603
2 changed files with 3 additions and 5 deletions

View file

@ -1,5 +1,6 @@
import { IAPIEmail, getDotComAPIEndpoint } from './api'
import { Account } from '../models/account'
import { isGHE } from './endpoint-capabilities'
/**
* Lookup a suitable email address to display in the application, based on the
@ -53,7 +54,7 @@ function isEmailPublic(email: IAPIEmail): boolean {
*/
function getStealthEmailHostForEndpoint(endpoint: string) {
const { hostname } = new URL(endpoint)
return endpoint === getDotComAPIEndpoint() || hostname.endsWith(`.ghe.com`)
return endpoint === getDotComAPIEndpoint() || isGHE(endpoint)
? 'users.noreply.github.com'
: `users.noreply.${hostname}`
}

View file

@ -5,7 +5,7 @@ import { Octicon } from '../octicons'
import { API, getDotComAPIEndpoint } from '../../lib/api'
import { TooltippedContent } from './tooltipped-content'
import { TooltipDirection } from './tooltip'
import { supportsAvatarsAPI } from '../../lib/endpoint-capabilities'
import { isGHE, supportsAvatarsAPI } from '../../lib/endpoint-capabilities'
import { Account } from '../../models/account'
import { offsetFrom } from '../../lib/offset-from'
import { ExpiringOperationCache } from './expiring-operation-cache'
@ -178,9 +178,6 @@ function getAvatarUrlCandidates(
return candidates
}
const isGHE = (endpoint: string) =>
new URL(endpoint).hostname.endsWith('ghe.com')
/** A component for displaying a user avatar. */
export class Avatar extends React.Component<IAvatarProps, IAvatarState> {
public static getDerivedStateFromProps(