@@ -180,13 +180,15 @@ func TestRender_AutoLink(t *testing.T) {
180
180
numericIssueLink (URLJoin (setting .AppSubURL , "issues" ), 3333 ))
181
181
182
182
// render external issue URLs
183
- tmp := "http://1111/2222/ssss-issues/3333?param=blah&blahh=333"
184
- test (tmp , "<a href=\" " + tmp + "\" >#3333 <i class='comment icon'></i></a>" )
185
- test ("http://test.com/issues/33333" , numericIssueLink ("http://test.com/issues" , 33333 ))
186
- test ("https://issues/333" , numericIssueLink ("https://issues" , 333 ))
183
+ for _ , externalURL := range []string {
184
+ "http://1111/2222/ssss-issues/3333?param=blah&blahh=333" ,
185
+ "http://test.com/issues/33333" ,
186
+ "https://issues/333" } {
187
+ test (externalURL , externalURL )
188
+ }
187
189
188
190
// render valid commit URLs
189
- tmp = URLJoin (AppSubURL , "commit" , "d8a994ef243349f321568f9e36d5c3f444b99cae" )
191
+ tmp : = URLJoin (AppSubURL , "commit" , "d8a994ef243349f321568f9e36d5c3f444b99cae" )
190
192
test (tmp , "<a href=\" " + tmp + "\" >d8a994ef24</a>" )
191
193
tmp += "#diff-2"
192
194
test (tmp , "<a href=\" " + tmp + "\" >d8a994ef24 (diff-2)</a>" )
@@ -332,6 +334,22 @@ func TestRender_CrossReferences(t *testing.T) {
332
334
`<p><a href="` + URLJoin (AppURL , "gogits" , "gogs" , "issues" , "12345" )+ `" rel="nofollow">gogits/gogs#12345</a></p>` )
333
335
}
334
336
337
+ func TestRender_FullIssueURLs (t * testing.T ) {
338
+ setting .AppURL = AppURL
339
+ setting .AppSubURL = AppSubURL
340
+
341
+ test := func (input , expected string ) {
342
+ result := RenderFullIssuePattern ([]byte (input ))
343
+ assert .Equal (t , expected , string (result ))
344
+ }
345
+ test ("Here is a link https://git.osgeo.org/gogs/postgis/postgis/pulls/6" ,
346
+ "Here is a link https://git.osgeo.org/gogs/postgis/postgis/pulls/6" )
347
+ test ("Look here http://localhost:3000/person/repo/issues/4" ,
348
+ `Look here <a href="http://localhost:3000/person/repo/issues/4">#4</a>` )
349
+ test ("http://localhost:3000/person/repo/issues/4#issuecomment-1234" ,
350
+ `<a href="http://localhost:3000/person/repo/issues/4#issuecomment-1234">#4</a>` )
351
+ }
352
+
335
353
func TestRegExp_MentionPattern (t * testing.T ) {
336
354
trueTestCases := []string {
337
355
"@Unknwon" ,
@@ -522,50 +540,6 @@ func TestRegExp_AnySHA1Pattern(t *testing.T) {
522
540
}
523
541
}
524
542
525
- func TestRegExp_IssueFullPattern (t * testing.T ) {
526
- testCases := map [string ][]string {
527
- "https://github.com/gogits/gogs/pull/3244" : {
528
- "https" ,
529
- "github.com/gogits/gogs/pull/" ,
530
- "3244" ,
531
- "" ,
532
- "" ,
533
- },
534
- "https://github.com/gogits/gogs/issues/3247#issuecomment-231517079" : {
535
- "https" ,
536
- "github.com/gogits/gogs/issues/" ,
537
- "3247" ,
538
- "#issuecomment-231517079" ,
539
- "" ,
540
- },
541
- "https://try.gogs.io/gogs/gogs/issues/4#issue-685" : {
542
- "https" ,
543
- "try.gogs.io/gogs/gogs/issues/" ,
544
- "4" ,
545
- "#issue-685" ,
546
- "" ,
547
- },
548
- "https://youtrack.jetbrains.com/issue/JT-36485" : {
549
- "https" ,
550
- "youtrack.jetbrains.com/issue/" ,
551
- "JT-36485" ,
552
- "" ,
553
- "" ,
554
- },
555
- "https://youtrack.jetbrains.com/issue/JT-36485#comment=27-1508676" : {
556
- "https" ,
557
- "youtrack.jetbrains.com/issue/" ,
558
- "JT-36485" ,
559
- "#comment=27-1508676" ,
560
- "" ,
561
- },
562
- }
563
-
564
- for k , v := range testCases {
565
- assert .Equal (t , IssueFullPattern .FindStringSubmatch (k )[1 :], v )
566
- }
567
- }
568
-
569
543
func TestMisc_IsMarkdownFile (t * testing.T ) {
570
544
setting .Markdown .FileExtensions = []string {".md" , ".markdown" , ".mdown" , ".mkd" }
571
545
trueTestCases := []string {
@@ -634,7 +608,7 @@ var sameCases = []string{
634
608
635
609
Ideas and codes
636
610
637
- - Bezier widget (by @r-lyeh) https://github.com/ ocornut/imgui/issues/786
611
+ - Bezier widget (by @r-lyeh) ` + AppURL + ` ocornut/imgui/issues/786
638
612
- Node graph editors https://github.com/ocornut/imgui/issues/306
639
613
- [[Memory Editor|memory_editor_example]]
640
614
- [[Plot var helper|plot_var_example]]` ,
@@ -670,8 +644,8 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
670
644
<p>Ideas and codes</p>
671
645
672
646
<ul>
673
- <li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>)<a href="https ://github.com /ocornut/imgui/issues/786" rel="nofollow">#786</a></li>
674
- <li>Node graph editors<a href=" https://github.com/ocornut/imgui/issues/306" rel="nofollow">#306</a> </li>
647
+ <li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="http ://localhost:3000 /ocornut/imgui/issues/786" rel="nofollow">#786</a></li>
648
+ <li>Node graph editors https://github.com/ocornut/imgui/issues/306</li>
675
649
<li><a href="` + baseURLContent + `memory_editor_example" rel="nofollow">Memory Editor</a></li>
676
650
<li><a href="` + baseURLContent + `plot_var_example" rel="nofollow">Plot var helper</a></li>
677
651
</ul>
0 commit comments