Skip to content

Commit 28aa745

Browse files
committed
clarify relative path behavior
1 parent dc92cb1 commit 28aa745

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

modules/markup/orgmode/orgmode_test.go

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,20 @@ import (
1010
"code.gitea.io/gitea/modules/git"
1111
"code.gitea.io/gitea/modules/markup"
1212
"code.gitea.io/gitea/modules/setting"
13-
"code.gitea.io/gitea/modules/util"
1413

1514
"github.com/stretchr/testify/assert"
1615
)
1716

18-
const (
19-
AppURL = "http://localhost:3000/"
20-
Repo = "gogits/gogs"
21-
AppSubURL = AppURL + Repo + "/"
22-
)
17+
const AppURL = "http://localhost:3000/"
2318

2419
func TestRender_StandardLinks(t *testing.T) {
2520
setting.AppURL = AppURL
26-
setting.AppSubURL = AppSubURL
2721

2822
test := func(input, expected string) {
2923
buffer, err := RenderString(&markup.RenderContext{
3024
Ctx: git.DefaultContext,
3125
Links: markup.Links{
32-
Base: setting.AppSubURL,
26+
Base: "/relative-path",
3327
},
3428
}, input)
3529
assert.NoError(t, err)
@@ -39,31 +33,28 @@ func TestRender_StandardLinks(t *testing.T) {
3933
test("[[https://google.com/]]",
4034
`<p><a href="https://google.com/">https://google.com/</a></p>`)
4135

42-
lnk := util.URLJoin(AppSubURL, "WikiPage")
43-
test("[[WikiPage][WikiPage]]",
44-
`<p><a href="`+lnk+`">WikiPage</a></p>`)
36+
test("[[WikiPage][The WikiPage Name]]",
37+
`<p><a href="/relative-path/WikiPage">The WikiPage Name</a></p>`)
4538
}
4639

4740
func TestRender_Media(t *testing.T) {
4841
setting.AppURL = AppURL
49-
setting.AppSubURL = AppSubURL
5042

5143
test := func(input, expected string) {
5244
buffer, err := RenderString(&markup.RenderContext{
5345
Ctx: git.DefaultContext,
5446
Links: markup.Links{
55-
Base: setting.AppSubURL,
47+
Base: "./relative-path",
5648
},
5749
}, input)
5850
assert.NoError(t, err)
5951
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
6052
}
6153

62-
url := "../../.images/src/02/train.jpg"
63-
result := util.URLJoin(AppSubURL, url)
64-
65-
test("[[file:"+url+"]]",
66-
`<p><img src="`+result+`" alt="`+result+`" /></p>`)
54+
test("[[file:../../.images/src/02/train.jpg]]",
55+
`<p><img src=".images/src/02/train.jpg" alt=".images/src/02/train.jpg" /></p>`)
56+
test("[[file:train.jpg]]",
57+
`<p><img src="relative-path/train.jpg" alt="relative-path/train.jpg" /></p>`)
6758

6859
// With description.
6960
test("[[https://example.com][https://example.com/example.svg]]",
@@ -94,7 +85,6 @@ func TestRender_Media(t *testing.T) {
9485

9586
func TestRender_Source(t *testing.T) {
9687
setting.AppURL = AppURL
97-
setting.AppSubURL = AppSubURL
9888

9989
test := func(input, expected string) {
10090
buffer, err := RenderString(&markup.RenderContext{

0 commit comments

Comments
 (0)