simplify addSuffixToFilePath

This commit is contained in:
Yury Semikhatsky 2024-03-08 15:39:43 -08:00
parent 4d10d72e91
commit 4286f7eda1

View file

@ -195,12 +195,10 @@ export function trimLongString(s: string, length = 100) {
return s.substring(0, start) + middle + s.slice(-end);
}
export function addSuffixToFilePath(filePath: string, suffix: string, customExtension?: string, sanitize = false): string {
const dirname = path.dirname(filePath);
export function addSuffixToFilePath(filePath: string, suffix: string): string {
const ext = path.extname(filePath);
const name = path.basename(filePath, ext);
const base = path.join(dirname, name);
return (sanitize ? sanitizeForFilePath(base) : base) + suffix + (customExtension || ext);
const base = filePath.substring(0, filePath.length - ext.length);
return base + suffix + ext;
}
/**