@@ -19,24 +19,50 @@ const AppURL = "http://localhost:3000/"
1919func TestRender_StandardLinks (t * testing.T ) {
2020 setting .AppURL = AppURL
2121
22- test := func (input , expected string ) {
22+ test := func (input , expected string , isWiki bool ) {
2323 buffer , err := RenderString (& markup.RenderContext {
2424 Ctx : git .DefaultContext ,
2525 Links : markup.Links {
2626 Base : "/relative-path" ,
2727 BranchPath : "branch/main" ,
2828 },
29+ IsWiki : isWiki ,
2930 }, input )
3031 assert .NoError (t , err )
3132 assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (buffer ))
3233 }
3334
3435 test ("[[https://google.com/]]" ,
35- `<p><a href="https://google.com/">https://google.com/</a></p>` )
36+ `<p><a href="https://google.com/">https://google.com/</a></p>` , false )
3637 test ("[[WikiPage][The WikiPage Desc]]" ,
37- `<p><a href="/relative-path/WikiPage">The WikiPage Desc</a></p>` )
38+ `<p><a href="/relative-path/wiki/ WikiPage">The WikiPage Desc</a></p>` , true )
3839 test ("[[ImageLink.svg][The Image Desc]]" ,
39- `<p><a href="/relative-path/media/branch/main/ImageLink.svg">The Image Desc</a></p>` )
40+ `<p><a href="/relative-path/media/branch/main/ImageLink.svg">The Image Desc</a></p>` , false )
41+ }
42+
43+ func TestRender_InternalLinks (t * testing.T ) {
44+ setting .AppURL = AppURL
45+
46+ test := func (input , expected string ) {
47+ buffer , err := RenderString (& markup.RenderContext {
48+ Ctx : git .DefaultContext ,
49+ Links : markup.Links {
50+ Base : "/relative-path" ,
51+ BranchPath : "branch/main" ,
52+ },
53+ }, input )
54+ assert .NoError (t , err )
55+ assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (buffer ))
56+ }
57+
58+ test ("[[file:test.org][Test]]" ,
59+ `<p><a href="/relative-path/src/branch/main/test.org">Test</a></p>` )
60+ test ("[[./test.org][Test]]" ,
61+ `<p><a href="/relative-path/src/branch/main/test.org">Test</a></p>` )
62+ test ("[[test.org][Test]]" ,
63+ `<p><a href="/relative-path/src/branch/main/test.org">Test</a></p>` )
64+ test ("[[path/to/test.org][Test]]" ,
65+ `<p><a href="/relative-path/src/branch/main/path/to/test.org">Test</a></p>` )
4066}
4167
4268func TestRender_Media (t * testing.T ) {
0 commit comments