mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-31 03:14:17 +09:00
fix(markup): keep commit title emoji inside links (#39986)
Render emoji inside the default commit-title link so the whole title remains clickable, including emoji-only titles. Explicit links and mentions keep their own destinations. Fixes https://github.com/go-gitea/gitea/issues/31873
This commit is contained in:
2 files changed
+20
-2
No files matched your search
@@ -136,6 +136,23 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
|
||||
assert.EqualValues(t, expected, newTestRenderUtils(t).RenderCommitMessageLinkSubject("see https://example.com/x here", "https://example.com/link", mockRepo))
|
||||
})
|
||||
|
||||
t.Run("RenderCommitMessageLinkSubjectEmoji", func(t *testing.T) {
|
||||
defer test.MockVariableValue(&setting.UI.CustomEmojisMap, map[string]string{"custom-emoji": ":custom-emoji:"})()
|
||||
for _, tt := range []struct {
|
||||
name, subject, content string
|
||||
}{
|
||||
{"native", "Bug ❌ Feature ✅", `Bug <span class="emoji" data-alias="x">❌</span> Feature <span class="emoji" data-alias="white_check_mark">✅</span>`},
|
||||
{"shortcode", "Ship :+1: today", `Ship <span class="emoji" data-alias="+1">👍</span> today`},
|
||||
{"emoji only", "👍", `<span class="emoji" data-alias="+1">👍</span>`},
|
||||
{"custom", "Ship :custom-emoji:", `Ship <span class="emoji"><img alt=":custom-emoji:" src="/assets/img/emoji/custom-emoji.png"/></span>`},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
expected := `<span class="title-full-link-hover"><a href="https://example.com/link" class="muted title-full-link">` + tt.content + `</a></span>`
|
||||
assert.EqualValues(t, expected, newTestRenderUtils(t).RenderCommitMessageLinkSubject(tt.subject, "https://example.com/link", mockRepo))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("RenderIssueTitle", func(t *testing.T) {
|
||||
defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableAdditionalAttributes, true)()
|
||||
expected := ` space @mention-user<SPACE><SPACE>
|
||||
|
||||
Reference in new issue
Block a user