Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/api/registry/badge/[type]/[...pkg].get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function measureTextWidth(text: string, font: string): number | null {

const measuredWidth = context.measureText(text).width

if (!Number.isNaN(measuredWidth)) {
if (Number.isFinite(measuredWidth) && measuredWidth > 0) {
return Math.ceil(measuredWidth)
Comment on lines +72 to 73
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adjusts the fallback behavior when measureText() returns 0, but there’s no regression test covering the measuredWidth === 0 case (which is the bug being fixed). Consider adding a Vitest test that mocks @napi-rs/canvas (or getCanvasContext()) to return width: 0 for a non-empty string and asserts that the computed badge/text width uses the character-count fallback (i.e., grows beyond the minimum width for longer strings).

Copilot generated this review using guidance from repository custom instructions.
}
}
Expand Down
Loading