refactor(util): remove unreachable path fallback

This commit is contained in:
imccyu
2026-08-23 23:29:46 +08:00
parent e791147203
commit 3e9c5d1bc9
+3 -1
View File
@@ -44,5 +44,7 @@ export function abbreviateHomePath(path: string, home?: string): string {
* @returns the final segment, or an empty string for a separator-only path.
*/
export function workspaceTitleOf(path: string): string {
return path.replace(/[/\\]+$/, '').split(/[/\\]/).pop() ?? ''
const trimmed = path.replace(/[/\\]+$/, '')
const separator = Math.max(trimmed.lastIndexOf('/'), trimmed.lastIndexOf('\\'))
return trimmed.slice(separator + 1)
}