Skip to content

Commit 6bbbd85

Browse files
authored
fix: badge label with empty string should not occupy width (#1095)
1 parent 1419fc7 commit 6bbbd85

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/api/registry/badge/[type]/[...pkg].get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export default defineCachedEventHandler(
292292
const rawLabelColor = labelColor ?? '#0a0a0a'
293293
const finalLabelColor = rawLabelColor?.startsWith('#') ? rawLabelColor : `#${rawLabelColor}`
294294

295-
const leftWidth = measureTextWidth(finalLabel)
295+
const leftWidth = finalLabel.trim().length === 0 ? 0 : measureTextWidth(finalLabel)
296296
const rightWidth = measureTextWidth(
297297
finalValue,
298298
CHARS_WIDTH[strategyKey as keyof typeof CHARS_WIDTH],

0 commit comments

Comments
 (0)