(name: string)
| 309 | * @returns A safe name (e.g., '-Users-foo-my-project' or 'plugin-name-server') |
| 310 | */ |
| 311 | export function sanitizePath(name: string): string { |
| 312 | const sanitized = name.replace(/[^a-zA-Z0-9]/g, '-') |
| 313 | if (sanitized.length <= MAX_SANITIZED_LENGTH) { |
| 314 | return sanitized |
| 315 | } |
| 316 | const hash = |
| 317 | typeof Bun !== 'undefined' ? Bun.hash(name).toString(36) : simpleHash(name) |
| 318 | return `${sanitized.slice(0, MAX_SANITIZED_LENGTH)}-${hash}` |
| 319 | } |
| 320 | |
| 321 | // --------------------------------------------------------------------------- |
| 322 | // Project directory discovery (shared by listSessions & getSessionMessages) |
no test coverage detected