0.12.0-9 Fix Jobs
This commit is contained in:
@@ -28,12 +28,21 @@ function transliterateForFilename(input) {
|
||||
|
||||
function sanitizeFileName(input) {
|
||||
return transliterateForFilename(String(input || 'untitled'))
|
||||
.replace(/[\\/:*?"<>|]/g, '_')
|
||||
.replace(/[^a-zA-Z0-9 ()[\]-]/g, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
.slice(0, 180);
|
||||
}
|
||||
|
||||
function sanitizeFileNameWithExtension(input) {
|
||||
const str = String(input || 'untitled');
|
||||
const ext = path.extname(str);
|
||||
const base = ext ? str.slice(0, -ext.length) : str;
|
||||
const cleanBase = sanitizeFileName(base);
|
||||
const cleanExt = ext.toLowerCase().replace(/[^a-z0-9.]/g, '');
|
||||
return (cleanBase || 'untitled') + cleanExt;
|
||||
}
|
||||
|
||||
function renderTemplate(template, values) {
|
||||
return String(template || '${title} (${year})').replace(/\$\{([^}]+)\}/g, (_, key) => {
|
||||
const val = values[key.trim()];
|
||||
@@ -86,6 +95,7 @@ module.exports = {
|
||||
ensureDir,
|
||||
transliterateForFilename,
|
||||
sanitizeFileName,
|
||||
sanitizeFileNameWithExtension,
|
||||
renderTemplate,
|
||||
findLargestMediaFile,
|
||||
findMediaFiles
|
||||
|
||||
Reference in New Issue
Block a user