Skip to content

Commit e67136b

Browse files
authored
fix: add helper snake to camle case (CM-1285) (#4258)
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 80d1eec commit e67136b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

backend/src/api/public/v1/packages/getPackage.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import { validateOrThrow } from '@/utils/validation'
1515
import { purlQuerySchema } from './purl'
1616
import type { StewardshipStatus } from './types'
1717

18+
function snakeToCamelKeys(obj: Record<string, unknown> | null): Record<string, unknown> | null {
19+
if (obj === null) return null
20+
return Object.fromEntries(
21+
Object.entries(obj).map(([k, v]) => [k.replace(/_([a-z])/g, (_, c) => c.toUpperCase()), v]),
22+
)
23+
}
24+
1825
function repoMappingLabel(confidence: number | null): 'High' | 'Medium' | 'Low' | null {
1926
if (confidence === null) return null
2027
if (confidence >= 0.8) return 'High'
@@ -75,7 +82,7 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
7582
openSSFScorecard: scorecardScore,
7683
},
7784
},
78-
signalCoverageHealth: pkg.signalCoverageHealth,
85+
signalCoverageHealth: snakeToCamelKeys(pkg.signalCoverageHealth),
7986
assessment: null,
8087
security: {
8188
securityContacts: null,

0 commit comments

Comments
 (0)