-
-
Notifications
You must be signed in to change notification settings - Fork 607
Expand file tree
/
Copy pathurl.ts
More file actions
16 lines (14 loc) · 552 Bytes
/
url.ts
File metadata and controls
16 lines (14 loc) · 552 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export function normalizeDomain(url: string | undefined): string | undefined {
if (!url) return undefined
return url.replace(/^https?:\/\//, "").replace(/\/+$/, "")
}
export function githubBaseUrl(enterprise?: string): string {
if (!enterprise) return "https://github.com"
const domain = normalizeDomain(enterprise)
return `https://${domain}`
}
export function githubApiBaseUrl(enterprise?: string): string {
if (!enterprise) return "https://api.github.com"
const domain = normalizeDomain(enterprise)
return `https://api.${domain}`
}