Revise isGhes logic (#511)

* Revise `isGhes` logic

* ran `npm run format`

* added unit test

* tweaked unit test

* ran `npm run format`
This commit is contained in:
John Wesley Walker III
2024-10-21 18:56:08 +02:00
committed by GitHub
parent d60b41a563
commit 941977282c
4 changed files with 55 additions and 3 deletions

6
dist/setup/index.js vendored
View File

@ -88165,7 +88165,11 @@ const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0,
exports.getCacheDirectoryPath = getCacheDirectoryPath;
function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
}
exports.isGhes = isGhes;
function isCacheFeatureAvailable() {