@@ -59,6 +59,31 @@ func testRenderIssueIndexPattern(t *testing.T, input, expected string, metas map
5959 string (RenderIssueIndexPattern ([]byte (input ), AppSubURL , metas )))
6060}
6161
62+ func TestURLJoin (t * testing.T ) {
63+ type test struct {
64+ Expected string
65+ Base string
66+ Elements []string
67+ }
68+ newTest := func (expected , base string , elements ... string ) test {
69+ return test {Expected : expected , Base : base , Elements : elements }
70+ }
71+ for _ , test := range []test {
72+ newTest ("https://try.gitea.io/a/b/c" ,
73+ "https://try.gitea.io" , "a/b" , "c" ),
74+ newTest ("https://try.gitea.io/a/b/c" ,
75+ "https://try.gitea.io/" , "/a/b/" , "/c/" ),
76+ newTest ("https://try.gitea.io/a/c" ,
77+ "https://try.gitea.io/" , "/a/./b/" , "../c/" ),
78+ newTest ("a/b/c" ,
79+ "a" , "b/c/" ),
80+ newTest ("a/b/d" ,
81+ "a/" , "b/c/" , "/../d/" ),
82+ } {
83+ assert .Equal (t , test .Expected , URLJoin (test .Base , test .Elements ... ))
84+ }
85+ }
86+
6287func TestRender_IssueIndexPattern (t * testing.T ) {
6388 // numeric: render inputs without valid mentions
6489 test := func (s string ) {
@@ -641,17 +666,17 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
641666 `<p>Wiki! Enjoy :)</p>
642667
643668<ul>
644- <li><a href="` + baseURLContent + `Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li>
645- <li><a href="` + baseURLContent + `Tips" rel="nofollow">Tips</a></li>
669+ <li><a href="` + baseURLContent + `/ Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li>
670+ <li><a href="` + baseURLContent + `/ Tips" rel="nofollow">Tips</a></li>
646671</ul>
647672
648673<p>Ideas and codes</p>
649674
650675<ul>
651676<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>
652677<li>Node graph editors<a href="https://github.com/ocornut/imgui/issues/306" rel="nofollow">#306</a></li>
653- <li><a href="` + baseURLContent + `memory_editor_example" rel="nofollow">Memory Editor</a></li>
654- <li><a href="` + baseURLContent + `plot_var_example" rel="nofollow">Plot var helper</a></li>
678+ <li><a href="` + baseURLContent + `/ memory_editor_example" rel="nofollow">Memory Editor</a></li>
679+ <li><a href="` + baseURLContent + `/ plot_var_example" rel="nofollow">Plot var helper</a></li>
655680</ul>
656681` ,
657682 `<h2>What is Wine Staging?</h2>
@@ -665,15 +690,15 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
665690<table>
666691<thead>
667692<tr>
668- <th><a href="` + baseURLImages + `images/icon-install.png" rel="nofollow"><img src="` + baseURLImages + `images/icon-install.png" alt="images/icon-install.png" title="icon-install.png"/></a></th>
669- <th><a href="` + baseURLContent + `Installation" rel="nofollow">Installation</a></th>
693+ <th><a href="` + baseURLImages + `/ images/icon-install.png" rel="nofollow"><img src="` + baseURLImages + `/ images/icon-install.png" alt="images/icon-install.png" title="icon-install.png"/></a></th>
694+ <th><a href="` + baseURLContent + `/ Installation" rel="nofollow">Installation</a></th>
670695</tr>
671696</thead>
672697
673698<tbody>
674699<tr>
675- <td><a href="` + baseURLImages + `images/icon-usage.png" rel="nofollow"><img src="` + baseURLImages + `images/icon-usage.png" alt="images/icon-usage.png" title="icon-usage.png"/></a></td>
676- <td><a href="` + baseURLContent + `Usage" rel="nofollow">Usage</a></td>
700+ <td><a href="` + baseURLImages + `/ images/icon-usage.png" rel="nofollow"><img src="` + baseURLImages + `/ images/icon-usage.png" alt="images/icon-usage.png" title="icon-usage.png"/></a></td>
701+ <td><a href="` + baseURLContent + `/ Usage" rel="nofollow">Usage</a></td>
677702</tr>
678703</tbody>
679704</table>
@@ -682,9 +707,9 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
682707
683708<ol>
684709<li><a href="https://github.com/libgdx/libgdx/wiki/Gradle-on-the-Commandline#packaging-for-the-desktop" rel="nofollow">Package your libGDX application</a>
685- <a href="` + baseURLImages + `images/1.png" rel="nofollow"><img src="` + baseURLImages + `images/1.png" alt="images/1.png" title="1.png"/></a></li>
710+ <a href="` + baseURLImages + `/ images/1.png" rel="nofollow"><img src="` + baseURLImages + `/ images/1.png" alt="images/1.png" title="1.png"/></a></li>
686711<li>Perform a test run by hitting the Run! button.
687- <a href="` + baseURLImages + `images/2.png" rel="nofollow"><img src="` + baseURLImages + `images/2.png" alt="images/2.png" title="2.png"/></a></li>
712+ <a href="` + baseURLImages + `/ images/2.png" rel="nofollow"><img src="` + baseURLImages + `/ images/2.png" alt="images/2.png" title="2.png"/></a></li>
688713</ol>
689714` ,
690715 }
0 commit comments