diff options
| author | Olcan <[email protected]> | 2025-05-19 16:58:57 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-19 16:58:57 -0700 |
| commit | 9c72a3ae129a5ab6cbc13fded86da01f2a354a75 (patch) | |
| tree | 772d6f405e6ce2858e3087f3b2f472a95a79642c /packages/server/src | |
| parent | 28acb8d495f847edc5c32e4d18b62bd08a9132d2 (diff) | |
ui tweaks (#442)
Diffstat (limited to 'packages/server/src')
| -rw-r--r-- | packages/server/src/utils/paths.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/server/src/utils/paths.ts b/packages/server/src/utils/paths.ts index 4ff74897..bbd479fd 100644 --- a/packages/server/src/utils/paths.ts +++ b/packages/server/src/utils/paths.ts @@ -5,6 +5,20 @@ */ import path from 'node:path'; +import os from 'os'; + +/** + * Replaces the home directory with a tilde. + * @param path - The path to tildeify. + * @returns The tildeified path. + */ +export function tildeifyPath(path: string): string { + const homeDir = os.homedir(); + if (path.startsWith(homeDir)) { + return path.replace(homeDir, '~'); + } + return path; +} /** * Shortens a path string if it exceeds maxLen, prioritizing the start and end segments. |
