Update formatUtil.ts (#2906)

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
This commit is contained in:
MohammadAboulEla
2025-03-07 22:06:26 +02:00
committed by GitHub
parent e4659a3930
commit d10dad85c6

View File

@@ -135,7 +135,7 @@ export function getPathDetails(path: string) {
* Replaces dots with underscores.
*/
export function normalizeI18nKey(key: string) {
return key.replace(/\./g, '_')
return typeof key === 'string' ? key.replace(/\./g, '_') : ''
}
/**
@@ -232,7 +232,9 @@ export function createAnnotatedPath(
const { rootFolder = 'input', subfolder } = options
if (typeof item === 'string')
return `${createPath(item, subfolder)}${createAnnotation(item, rootFolder)}`
return `${createPath(item.filename ?? '', item.subfolder)}${item.type ? createAnnotation(item.type, rootFolder) : ''}`
return `${createPath(item.filename ?? '', item.subfolder)}${
item.type ? createAnnotation(item.type, rootFolder) : ''
}`
}
/**