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