@@ -19,24 +19,50 @@ const AppURL = "http://localhost:3000/"
19
19
func TestRender_StandardLinks (t * testing.T ) {
20
20
setting .AppURL = AppURL
21
21
22
- test := func (input , expected string ) {
22
+ test := func (input , expected string , isWiki bool ) {
23
23
buffer , err := RenderString (& markup.RenderContext {
24
24
Ctx : git .DefaultContext ,
25
25
Links : markup.Links {
26
26
Base : "/relative-path" ,
27
27
BranchPath : "branch/main" ,
28
28
},
29
+ IsWiki : isWiki ,
29
30
}, input )
30
31
assert .NoError (t , err )
31
32
assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (buffer ))
32
33
}
33
34
34
35
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 )
36
37
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 )
38
39
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>` )
40
66
}
41
67
42
68
func TestRender_Media (t * testing.T ) {
0 commit comments