fix: use Map for abbreviations to handle mixed-case DevOps label

This commit is contained in:
Jennie Robinson Faber 2026-04-05 16:13:23 +01:00
parent 1cb029a881
commit 18b8106405

View file

@ -12,15 +12,17 @@ import { connectDB } from '../server/utils/mongoose.js'
// Convert a slug like "qa-and-testing" to "QA and Testing"
// Special-cases common abbreviations.
const ABBREVIATIONS = new Set(['qa', 'ux', 'ui', 'devops'])
const ABBREVIATIONS = new Map([
['qa', 'QA'],
['ux', 'UX'],
['ui', 'UI'],
['devops', 'DevOps'],
])
function slugToLabel(slug) {
return slug
.split('-')
.map((word) => {
if (ABBREVIATIONS.has(word)) return word.toUpperCase()
return word.charAt(0).toUpperCase() + word.slice(1)
})
.map((word) => ABBREVIATIONS.get(word) ?? word.charAt(0).toUpperCase() + word.slice(1))
.join(' ')
}