fix: use Map for abbreviations to handle mixed-case DevOps label
This commit is contained in:
parent
1cb029a881
commit
18b8106405
1 changed files with 7 additions and 5 deletions
|
|
@ -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(' ')
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue