Fix badge image by correctly encoding the URI components

This commit is contained in:
Jozef Izso 2025-11-05 21:18:09 +01:00
parent c883ae9738
commit de77f76b7e
Failed to extract signature

View file

@ -145,8 +145,10 @@ function getBadge(passed: number, failed: number, skipped: number, options: Repo
color = 'yellow'
}
const hint = failed > 0 ? 'Tests failed' : 'Tests passed successfully'
const uri = encodeURIComponent(`${options.badgeTitle}-${message}-${color}`)
return `![${hint}](https://img.shields.io/badge/${uri})`
const encodedBadgeTitle = encodeImgShieldsURIComponent(options.badgeTitle)
const encodedMessage = encodeImgShieldsURIComponent(message)
const encodedColor = encodeImgShieldsURIComponent(color)
return `![${hint}](https://img.shields.io/badge/${encodedBadgeTitle}-${encodedMessage}-${encodedColor})`
}
function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): string[] {
@ -305,3 +307,7 @@ function getResultIcon(result: TestExecutionResult): string {
return ''
}
}
function encodeImgShieldsURIComponent(component: string): string {
return encodeURIComponent(component).replace(/-/g, '--')
}