mirror of
https://github.com/stablyai/orca.git
synced 2026-10-22 08:03:37 +00:00
14 lines
587 B
TypeScript
14 lines
587 B
TypeScript
import { t } from '@/i18n/mobile-i18n'
|
|
// Why: worktree ids encode `repo::path`; screens that only receive the id
|
|
// (deep links, route params without a name) still need a human label.
|
|
export function getWorktreeLabel(name: string | undefined, worktreeId: string): string {
|
|
if (name?.trim()) {
|
|
return name.trim()
|
|
}
|
|
const pathPart = worktreeId.includes('::')
|
|
? worktreeId.slice(worktreeId.indexOf('::') + 2)
|
|
: worktreeId
|
|
const normalized = pathPart.replace(/\\/g, '/').replace(/\/+$/, '')
|
|
return normalized.slice(normalized.lastIndexOf('/') + 1) || t('m.bdYtRH8')
|
|
}
|