Skip to content

Commit e733bdc

Browse files
committed
clarify relative path behavior
1 parent dc92cb1 commit e733bdc

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

modules/markup/orgmode/orgmode_test.go

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,19 @@ 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"
14-
1513
"github.com/stretchr/testify/assert"
1614
)
1715

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

2418
func TestRender_StandardLinks(t *testing.T) {
2519
setting.AppURL = AppURL
26-
setting.AppSubURL = AppSubURL
2720

2821
test := func(input, expected string) {
2922
buffer, err := RenderString(&markup.RenderContext{
3023
Ctx: git.DefaultContext,
3124
Links: markup.Links{
32-
Base: setting.AppSubURL,
25+
Base: "/relative-path",
3326
},
3427
}, input)
3528
assert.NoError(t, err)
@@ -39,31 +32,28 @@ func TestRender_StandardLinks(t *testing.T) {
3932
test("[[https://google.com/]]",
4033
`<p><a href="https://google.com/">https://google.com/</a></p>`)
4134

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

4739
func TestRender_Media(t *testing.T) {
4840
setting.AppURL = AppURL
49-
setting.AppSubURL = AppSubURL
5041

5142
test := func(input, expected string) {
5243
buffer, err := RenderString(&markup.RenderContext{
5344
Ctx: git.DefaultContext,
5445
Links: markup.Links{
55-
Base: setting.AppSubURL,
46+
Base: "./relative-path",
5647
},
5748
}, input)
5849
assert.NoError(t, err)
5950
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
6051
}
6152

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>`)
53+
test("[[file:../../.images/src/02/train.jpg]]",
54+
`<p><img src=".images/src/02/train.jpg" alt=".images/src/02/train.jpg" /></p>`)
55+
test("[[file:train.jpg]]",
56+
`<p><img src="relative-path/train.jpg" alt="relative-path/train.jpg" /></p>`)
6757

6858
// With description.
6959
test("[[https://example.com][https://example.com/example.svg]]",
@@ -94,7 +84,6 @@ func TestRender_Media(t *testing.T) {
9484

9585
func TestRender_Source(t *testing.T) {
9686
setting.AppURL = AppURL
97-
setting.AppSubURL = AppSubURL
9887

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

0 commit comments

Comments
 (0)