coding-agent: fix macOS screenshot filenames with unicode spaces (#181)

This commit is contained in:
Nico Bailon 2025-12-13 13:04:01 -08:00 committed by GitHub
parent 5c0a84b2d8
commit 9a7bbb2839
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 70 additions and 108 deletions

View file

@ -44,17 +44,21 @@ export interface LoadHooksResult {
errors: Array<{ path: string; error: string }>;
}
/**
* Expand path with ~ support.
*/
const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
function normalizeUnicodeSpaces(str: string): string {
return str.replace(UNICODE_SPACES, " ");
}
function expandPath(p: string): string {
if (p.startsWith("~/")) {
return path.join(os.homedir(), p.slice(2));
const normalized = normalizeUnicodeSpaces(p);
if (normalized.startsWith("~/")) {
return path.join(os.homedir(), normalized.slice(2));
}
if (p.startsWith("~")) {
return path.join(os.homedir(), p.slice(1));
if (normalized.startsWith("~")) {
return path.join(os.homedir(), normalized.slice(1));
}
return p;
return normalized;
}
/**