chore: don't sanitize file extension away (#327)

This commit is contained in:
Simon Knott 2025-05-02 19:58:48 +02:00 committed by GitHub
parent 062cdd0704
commit 2c9376e50f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View file

@ -70,6 +70,13 @@ export async function waitForCompletion<R>(context: Context, page: playwright.Pa
}
}
export function sanitizeForFilePath(s: string) {
function sanitize(s: string) {
return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
}
export function sanitizeForFilePath(s: string) {
const separator = s.lastIndexOf('.');
if (separator === -1)
return sanitize(s);
return sanitize(s.substring(0, separator)) + '.' + sanitize(s.substring(separator + 1));
}