0.10.2-7 Layout/Chars
This commit is contained in:
@@ -5,8 +5,29 @@ function ensureDir(dirPath) {
|
||||
fs.mkdirSync(dirPath, { recursive: true });
|
||||
}
|
||||
|
||||
function transliterateForFilename(input) {
|
||||
return String(input || '')
|
||||
// German — must come before NFD to get ae/oe/ue instead of just a/o/u
|
||||
.replace(/ä/g, 'ae').replace(/Ä/g, 'Ae')
|
||||
.replace(/ö/g, 'oe').replace(/Ö/g, 'Oe')
|
||||
.replace(/ü/g, 'ue').replace(/Ü/g, 'Ue')
|
||||
.replace(/ß/g, 'ss')
|
||||
// Danish / Norwegian / Swedish
|
||||
.replace(/å/g, 'a').replace(/Å/g, 'A')
|
||||
.replace(/æ/g, 'ae').replace(/Æ/g, 'Ae')
|
||||
.replace(/ø/g, 'o').replace(/Ø/g, 'O')
|
||||
// Icelandic
|
||||
.replace(/ð/g, 'd').replace(/Ð/g, 'D')
|
||||
.replace(/þ/g, 'th').replace(/Þ/g, 'Th')
|
||||
// NFD decomposition + strip combining diacritical marks (handles é→e, ñ→n, ç→c, etc.)
|
||||
.normalize('NFD')
|
||||
.replace(/\p{M}+/gu, '')
|
||||
// Drop any remaining non-ASCII characters
|
||||
.replace(/[^\x00-\x7F]/g, '');
|
||||
}
|
||||
|
||||
function sanitizeFileName(input) {
|
||||
return String(input || 'untitled')
|
||||
return transliterateForFilename(String(input || 'untitled'))
|
||||
.replace(/[\\/:*?"<>|]/g, '_')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
@@ -63,6 +84,7 @@ function findMediaFiles(dirPath, extensions = ['.mkv', '.mp4']) {
|
||||
|
||||
module.exports = {
|
||||
ensureDir,
|
||||
transliterateForFilename,
|
||||
sanitizeFileName,
|
||||
renderTemplate,
|
||||
findLargestMediaFile,
|
||||
|
||||
Reference in New Issue
Block a user