15 lines
519 B
TypeScript
15 lines
519 B
TypeScript
import type { Issue } from '../types'
|
|
import { FORGE_NAMES, forgeKindForHost } from '../../../src/forge/types'
|
|
|
|
/** 工单所在系统的名字,用在「在 GitHub 打开」这类文案里;代码托管工单看网页地址的 host 认是哪一家。 */
|
|
export function trackerName(issue: Pick<Issue, 'source' | 'htmlUrl'>): string {
|
|
if (issue.source === 'youtrack')
|
|
return 'YouTrack'
|
|
let host = ''
|
|
try {
|
|
host = new URL(issue.htmlUrl).host
|
|
}
|
|
catch {}
|
|
return FORGE_NAMES[forgeKindForHost(host)]
|
|
}
|