Compare commits

...

4 Commits

Author SHA1 Message Date
John Wesley Walker III
7695871fe0 ran npm run build 2024-10-17 17:50:52 +00:00
John Wesley Walker III
914445f9e7 Responded to PR feedback. 2024-10-17 17:46:35 +00:00
John Wesley Walker III
041723abcc updated unit tests 2024-10-17 11:56:31 +00:00
John Wesley Walker III
813c3f2d82
Apply suggestions from @easyt
Co-authored-by: Erez Testiler <easyt@github.com>
2024-10-17 13:49:31 +02:00
3 changed files with 12 additions and 13 deletions

View File

@ -4,10 +4,9 @@ describe('isGhes tests', () => {
it('basics', async () => {
expect(urlHelper.isGhes()).toBeFalsy()
expect(urlHelper.isGhes('https://github.com')).toBeFalsy()
//expect(urlHelper.isGhes('https://api.github.com')).toBeFalsy()
expect(urlHelper.isGhes('https://europe.ghe.com')).toBeFalsy()
expect(urlHelper.isGhes('https://contoso.ghe.com')).toBeFalsy()
expect(urlHelper.isGhes('https://test.github.localhost')).toBeFalsy()
expect(urlHelper.isGhes('https://src.onpremise.customer.com')).toBeTruthy()
expect(urlHelper.isGhes('https://src.onpremise.fabrikam.com')).toBeTruthy()
})
})
@ -20,14 +19,14 @@ describe('getServerApiUrl tests', () => {
expect(urlHelper.getServerApiUrl('https://GitHub.com')).toBe(
'https://api.github.com'
)
expect(urlHelper.getServerApiUrl('https://europe.ghe.com')).toBe(
'https://api.europe.ghe.com'
expect(urlHelper.getServerApiUrl('https://contoso.ghe.com')).toBe(
'https://api.contoso.ghe.com'
)
expect(urlHelper.getServerApiUrl('https://australia.GHE.COM')).toBe(
'https://api.australia.ghe.com'
expect(urlHelper.getServerApiUrl('https://fabrikam.GHE.COM')).toBe(
'https://api.fabrikam.ghe.com'
)
expect(
urlHelper.getServerApiUrl('https://src.onpremise.customer.com')
).toBe('https://src.onpremise.customer.com/api/v3')
urlHelper.getServerApiUrl('https://src.onpremise.fabrikam.com')
).toBe('https://src.onpremise.fabrikam.com/api/v3')
})
})

4
dist/index.js vendored
View File

@ -2477,9 +2477,9 @@ function isGhes(url) {
const ghUrl = new url_1.URL(url || process.env['GITHUB_SERVER_URL'] || 'https://github.com');
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGheHost = hostname.endsWith('.GHE.COM');
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGheHost && !isLocalHost;
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
}
function pruneSuffix(text, suffix) {
if (hasContent(suffix, true) && (text === null || text === void 0 ? void 0 : text.endsWith(suffix))) {

View File

@ -51,10 +51,10 @@ export function isGhes(url?: string): boolean {
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
const isGitHubHost = hostname === 'GITHUB.COM'
const isGheHost = hostname.endsWith('.GHE.COM')
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM')
const isLocalHost = hostname.endsWith('.LOCALHOST')
return !isGitHubHost && !isGheHost && !isLocalHost
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost
}
function pruneSuffix(text: string, suffix: string) {