From 3e9c5d1bc93a00355382cd26e7fbb869a35e4d70 Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Sun, 23 Aug 2026 23:29:46 +0800 Subject: [PATCH] refactor(util): remove unreachable path fallback --- packages/util/workspace-path/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/util/workspace-path/src/index.ts b/packages/util/workspace-path/src/index.ts index 9b9f559337..4f8dbf2f21 100644 --- a/packages/util/workspace-path/src/index.ts +++ b/packages/util/workspace-path/src/index.ts @@ -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) }