15 lines
369 B
JavaScript
15 lines
369 B
JavaScript
|
|
export const formatExtensionCardTitle = (value) => {
|
||
|
|
const text = String(value || '').trim()
|
||
|
|
if (!text) return ''
|
||
|
|
|
||
|
|
return text
|
||
|
|
.replace(/[-_]+/g, ' ')
|
||
|
|
.split(/\s+/)
|
||
|
|
.filter(Boolean)
|
||
|
|
.map((word) => {
|
||
|
|
if (/^[A-Z0-9]{2,3}$/.test(word)) return word
|
||
|
|
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
||
|
|
})
|
||
|
|
.join(' ')
|
||
|
|
}
|