Restart repository history from target event
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import sanitize from 'sanitize-filename';
|
||||
|
||||
export function sanitizeName(name: string): string {
|
||||
// Use the same logic as album name to keep consistency and allow brackets
|
||||
return sanitizeAlbumName(name);
|
||||
}
|
||||
|
||||
export function sanitizeAlbumName(name: string): string {
|
||||
// 1. Replace " / " or "/" with ", "
|
||||
let clean = name.replace(/\s*\/\s*/g, ', ');
|
||||
|
||||
// 1.5 Replace "&" with "and"
|
||||
clean = clean.replace(/&/g, 'and');
|
||||
|
||||
// 2. Remove accents/diacritics (e.g. "Espírito" -> "Espirito")
|
||||
// Note: Re-normalizing to NFC to correctly recompose Korean Hangul characters
|
||||
clean = clean.normalize("NFD").replace(/[\u0300-\u036f]/g, "").normalize("NFC");
|
||||
|
||||
// 3. Remove non-ascii characters but keep [], (), spaces, hyphens and plus signs.
|
||||
// Also allow Asian characters (Chinese, Japanese, Korean) along with CJK punctuation.
|
||||
const allowed = /[^a-zA-Z0-9 \-_.\[\](),+\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\u3000-\u303F\uFF00-\uFFEF]/gu;
|
||||
|
||||
clean = clean.replace(allowed, '');
|
||||
|
||||
// 4. Remove double spaces
|
||||
clean = clean.replace(/\s+/g, ' ');
|
||||
|
||||
return clean.trim();
|
||||
}
|
||||
Reference in New Issue
Block a user