@@ -209,13 +209,15 @@ func TestRender_AutoLink(t *testing.T) {
209
209
numericIssueLink (URLJoin (setting .AppSubURL , "issues" ), 3333 ))
210
210
211
211
// render external issue URLs
212
- tmp := "http://1111/2222/ssss-issues/3333?param=blah&blahh=333"
213
- test (tmp , "<a href=\" " + tmp + "\" >#3333 <i class='comment icon'></i></a>" )
214
- test ("http://test.com/issues/33333" , numericIssueLink ("http://test.com/issues" , 33333 ))
215
- test ("https://issues/333" , numericIssueLink ("https://issues" , 333 ))
212
+ for _ , externalURL := range []string {
213
+ "http://1111/2222/ssss-issues/3333?param=blah&blahh=333" ,
214
+ "http://test.com/issues/33333" ,
215
+ "https://issues/333" } {
216
+ test (externalURL , externalURL )
217
+ }
216
218
217
219
// render valid commit URLs
218
- tmp = URLJoin (AppSubURL , "commit" , "d8a994ef243349f321568f9e36d5c3f444b99cae" )
220
+ tmp : = URLJoin (AppSubURL , "commit" , "d8a994ef243349f321568f9e36d5c3f444b99cae" )
219
221
test (tmp , "<a href=\" " + tmp + "\" >d8a994ef24</a>" )
220
222
tmp += "#diff-2"
221
223
test (tmp , "<a href=\" " + tmp + "\" >d8a994ef24 (diff-2)</a>" )
@@ -368,6 +370,22 @@ func TestRender_CrossReferences(t *testing.T) {
368
370
`<p><a href="` + URLJoin (AppURL , "gogits" , "gogs" , "issues" , "12345" )+ `" rel="nofollow">gogits/gogs#12345</a></p>` )
369
371
}
370
372
373
+ func TestRender_FullIssueURLs (t * testing.T ) {
374
+ setting .AppURL = AppURL
375
+ setting .AppSubURL = AppSubURL
376
+
377
+ test := func (input , expected string ) {
378
+ result := RenderFullIssuePattern ([]byte (input ))
379
+ assert .Equal (t , expected , string (result ))
380
+ }
381
+ test ("Here is a link https://git.osgeo.org/gogs/postgis/postgis/pulls/6" ,
382
+ "Here is a link https://git.osgeo.org/gogs/postgis/postgis/pulls/6" )
383
+ test ("Look here http://localhost:3000/person/repo/issues/4" ,
384
+ `Look here <a href="http://localhost:3000/person/repo/issues/4">#4</a>` )
385
+ test ("http://localhost:3000/person/repo/issues/4#issuecomment-1234" ,
386
+ `<a href="http://localhost:3000/person/repo/issues/4#issuecomment-1234">#4</a>` )
387
+ }
388
+
371
389
func TestRegExp_MentionPattern (t * testing.T ) {
372
390
trueTestCases := []string {
373
391
"@Unknwon" ,
@@ -558,50 +576,6 @@ func TestRegExp_AnySHA1Pattern(t *testing.T) {
558
576
}
559
577
}
560
578
561
- func TestRegExp_IssueFullPattern (t * testing.T ) {
562
- testCases := map [string ][]string {
563
- "https://github.com/gogits/gogs/pull/3244" : {
564
- "https" ,
565
- "github.com/gogits/gogs/pull/" ,
566
- "3244" ,
567
- "" ,
568
- "" ,
569
- },
570
- "https://github.com/gogits/gogs/issues/3247#issuecomment-231517079" : {
571
- "https" ,
572
- "github.com/gogits/gogs/issues/" ,
573
- "3247" ,
574
- "#issuecomment-231517079" ,
575
- "" ,
576
- },
577
- "https://try.gogs.io/gogs/gogs/issues/4#issue-685" : {
578
- "https" ,
579
- "try.gogs.io/gogs/gogs/issues/" ,
580
- "4" ,
581
- "#issue-685" ,
582
- "" ,
583
- },
584
- "https://youtrack.jetbrains.com/issue/JT-36485" : {
585
- "https" ,
586
- "youtrack.jetbrains.com/issue/" ,
587
- "JT-36485" ,
588
- "" ,
589
- "" ,
590
- },
591
- "https://youtrack.jetbrains.com/issue/JT-36485#comment=27-1508676" : {
592
- "https" ,
593
- "youtrack.jetbrains.com/issue/" ,
594
- "JT-36485" ,
595
- "#comment=27-1508676" ,
596
- "" ,
597
- },
598
- }
599
-
600
- for k , v := range testCases {
601
- assert .Equal (t , IssueFullPattern .FindStringSubmatch (k )[1 :], v )
602
- }
603
- }
604
-
605
579
func TestMisc_IsMarkdownFile (t * testing.T ) {
606
580
setting .Markdown .FileExtensions = []string {".md" , ".markdown" , ".mdown" , ".mkd" }
607
581
trueTestCases := []string {
@@ -645,7 +619,7 @@ var sameCases = []string{
645
619
646
620
Ideas and codes
647
621
648
- - Bezier widget (by @r-lyeh) https://github.com/ ocornut/imgui/issues/786
622
+ - Bezier widget (by @r-lyeh) ` + AppURL + ` ocornut/imgui/issues/786
649
623
- Node graph editors https://github.com/ocornut/imgui/issues/306
650
624
- [[Memory Editor|memory_editor_example]]
651
625
- [[Plot var helper|plot_var_example]]` ,
@@ -681,8 +655,8 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
681
655
<p>Ideas and codes</p>
682
656
683
657
<ul>
684
- <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>
685
- <li>Node graph editors<a href=" https://github.com/ocornut/imgui/issues/306" rel="nofollow">#306</a> </li>
658
+ <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>
659
+ <li>Node graph editors https://github.com/ocornut/imgui/issues/306</li>
686
660
<li><a href="` + baseURLContent + `/memory_editor_example" rel="nofollow">Memory Editor</a></li>
687
661
<li><a href="` + baseURLContent + `/plot_var_example" rel="nofollow">Plot var helper</a></li>
688
662
</ul>
0 commit comments