Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getServerUrl refers to the GITHUB_SERVER_URL environment variable #169

Merged
merged 4 commits into from
May 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ async function capture(cmd: string, args: string[]): Promise<ExecResult> {
}
}

export function getServerUrlObj(repositoryUrl: string | undefined): URL {
const urlValue =
repositoryUrl && repositoryUrl.trim().length > 0
? repositoryUrl
: process.env['GITHUB_SERVER_URL'] ?? DEFAULT_GITHUB_URL;
return new URL(urlValue);
}

export function getServerUrl(repositoryUrl: string | undefined): string {
const urlObj = repositoryUrl ? new URL(repositoryUrl) : new URL(DEFAULT_GITHUB_URL);
return repositoryUrl ? urlObj.origin : DEFAULT_GITHUB_URL;
return getServerUrlObj(repositoryUrl).origin;
}

export function getServerName(repositoryUrl: string | undefined): string {
const urlObj = repositoryUrl ? new URL(repositoryUrl) : new URL(DEFAULT_GITHUB_URL);
return repositoryUrl ? urlObj.hostname : DEFAULT_GITHUB_URL.replace('https://', '');
return getServerUrlObj(repositoryUrl).hostname;
}

export async function cmd(additionalGitOptions: string[], ...args: string[]): Promise<string> {
Expand Down