Files
paseo/packages/app/src/utils/shorten-path.ts
T

11 lines
316 B
TypeScript

/**
* Shortens a file path by replacing the home directory prefix with ~.
* Handles both macOS (/Users/username) and Linux (/home/username) paths.
*/
export function shortenPath(path: string | undefined | null): string {
if (!path) {
return "";
}
return path.replace(/^\/(?:Users|home)\/[^/]+/, "~");
}