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) }