From c4b8348109f457beddb63877d105906a7cf4ff5f Mon Sep 17 00:00:00 2001 From: SK Akram Date: Wed, 31 Dec 2025 06:14:44 +0000 Subject: [PATCH] fix: correct empty string escaping and path tildeification edge cases --- packages/core/src/utils/paths.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/src/utils/paths.ts b/packages/core/src/utils/paths.ts index 4163f26..f8ff5cc 100644 --- a/packages/core/src/utils/paths.ts +++ b/packages/core/src/utils/paths.ts @@ -23,12 +23,15 @@ export const SHELL_SPECIAL_CHARS = /[ \t()[\]{};|*?$`'"#&<>!~]/; * @param path - The path to tildeify. * @returns The tildeified path. */ -export function tildeifyPath(path: string): string { +export function tildeifyPath(p: string): string { const homeDir = os.homedir(); - if (path.startsWith(homeDir)) { - return path.replace(homeDir, '~'); + if (p === homeDir) { + return '~'; } - return path; + if (p.startsWith(homeDir + path.sep)) { + return '~' + p.substring(homeDir.length); + } + return p; } /**