Skip to content

Commit bcc28aa

Browse files
committed
Trim text spaces
1 parent ca43caf commit bcc28aa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/badge/badge.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package badge
55

66
import (
7+
"strings"
78
"unicode"
89

910
actions_model "code.gitea.io/gitea/models/actions"
@@ -93,7 +94,7 @@ func GenerateBadge(label, message, color string) Badge {
9394
func calculateTextWidth(text string) int {
9495
width := 0
9596

96-
for _, char := range text {
97+
for _, char := range strings.TrimSpace(text) {
9798
charWidth, ok := DejaVuGlyphWidthData[char]
9899
if !ok {
99100
// use the width of 'm' in case of missing glyph width data for a printable character

0 commit comments

Comments
 (0)