api/language-codes: prevent errors if code is undefined

This commit is contained in:
wukko 2025-07-01 16:32:39 +06:00
parent 810e0a865c
commit f3992fbe33
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2

View File

@ -49,6 +49,6 @@ const maps = {
}
export const convertLanguageCode = (code) => {
code = code.split("-")[0].split("_")[0];
code = code?.split("-")[0]?.split("_")[0] || "";
return maps[code.length]?.[code.toLowerCase()] || null;
}