@@ -225,10 +225,10 @@ func TestRender_email(t *testing.T) {
225225 test := func (input , expected string ) {
226226 res , err := markup .RenderString (markup .NewTestRenderContext ().WithRelativePath ("a.md" ), input )
227227 assert .NoError (t , err )
228- assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (res ))
228+ assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (res ), "input: %s" , input )
229229 }
230- // Text that should be turned into email link
231230
231+ // Text that should be turned into email link
232232 test (
233233234234 `<p><a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` )
@@ -259,28 +259,23 @@ func TestRender_email(t *testing.T) {
259259<a href="mailto:[email protected] " rel="nofollow">[email protected] </a>; 260260<a href="mailto:[email protected] " rel="nofollow">[email protected] </a>? 261261<a href="mailto:[email protected] " rel="nofollow">[email protected] </a>!</p>` )
262- test (
263- 264- `<p>?<a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` )
265- test (
266- 267- `<p>*<a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` )
268- test (
269- 270- `<p>~<a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` )
271- test (
272- 273- `<p>email@<a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` )
262+
263+ // match GitHub behavior
264+ test (
"email@[email protected] " ,
`<p>email@<a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` )
265+
266+ // match GitHub behavior
267+ test (
`"[email protected] "` ,
`<p>"<a href="mailto:[email protected] " rel="nofollow">[email protected] </a>"</p>` )
268+
274269 // Test that should *not* be turned into email links
275- test (
276- 277- `<p>"[email protected] "</p>` )
278270 test (
279271 "/home/gitea/mailstore/info@gitea/com" ,
280272 `<p>/home/gitea/mailstore/info@gitea/com</p>` )
281273 test (
282274 "[email protected] :go-gitea/gitea.git" ,
283275 `<p>[email protected] :go-gitea/gitea.git</p>` )
276+ test (
277+ 278+ `<p><a href="https://foo:[email protected] " rel="nofollow">https://foo:[email protected] </a></p>` )
284279 test (
285280 "gitea@3" ,
286281 `<p>gitea@3</p>` )
@@ -290,6 +285,18 @@ func TestRender_email(t *testing.T) {
290285 test (
291286292287288+
289+ cases := []struct {
290+ input , expected string
291+ }{
292+ // match GitHub behavior
293+ {
"[email protected] " ,
`<p>?<a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` },
294+ {
"*[email protected] " ,
`<p>*<a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` },
295+ {
"[email protected] " ,
`<p>~<a href="mailto:[email protected] " rel="nofollow">[email protected] </a></p>` },
296+ }
297+ for _ , c := range cases {
298+ test (c .input , c .expected )
299+ }
293300}
294301
295302func TestRender_emoji (t * testing.T ) {
0 commit comments