diff options
author | Giteabot <teabot@gitea.io> | 2024-06-22 05:03:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-22 00:03:31 +0300 |
commit | be302f302596a83ff6bd610a5177def245f96fde (patch) | |
tree | a22829a3c37fc87ec3a475e3eef6133ecae8abc4 /modules/markup/html_test.go | |
parent | a3529d662f1fd90d59314f518ad225f87f913972 (diff) | |
download | gitea-be302f302596a83ff6bd610a5177def245f96fde.tar.gz gitea-be302f302596a83ff6bd610a5177def245f96fde.zip |
Support relative paths to videos from Wiki pages (#31061) (#31453)
Backport #31061 by @sergeyvfx
This change fixes cases when a Wiki page refers to a video stored in the
Wiki repository using relative path. It follows the similar case which
has been already implemented for images.
Test plan:
- Create repository and Wiki page
- Clone the Wiki repository
- Add video to it, say `video.mp4`
- Modify the markdown file to refer to the video using `<video
src="video.mp4">`
- Commit the Wiki page
- Observe that the video is properly displayed
Co-authored-by: Sergey Sharybin <sergey.vfx@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules/markup/html_test.go')
-rw-r--r-- | modules/markup/html_test.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 64cc30d246..8911bf3f2e 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -520,7 +520,7 @@ func TestRender_ShortLinks(t *testing.T) { `<p><a href="https://example.org" rel="nofollow">[[foobar]]</a></p>`) } -func TestRender_RelativeImages(t *testing.T) { +func TestRender_RelativeMedias(t *testing.T) { render := func(input string, isWiki bool, links markup.Links) string { buffer, err := markdown.RenderString(&markup.RenderContext{ Ctx: git.DefaultContext, @@ -546,6 +546,15 @@ func TestRender_RelativeImages(t *testing.T) { out = render(`<img src="/LINK">`, true, markup.Links{Base: "/test-owner/test-repo", BranchPath: "test-branch"}) assert.Equal(t, `<img src="/LINK"/>`, out) + + out = render(`<video src="LINK">`, false, markup.Links{Base: "/test-owner/test-repo"}) + assert.Equal(t, `<video src="/test-owner/test-repo/LINK"></video>`, out) + + out = render(`<video src="LINK">`, true, markup.Links{Base: "/test-owner/test-repo"}) + assert.Equal(t, `<video src="/test-owner/test-repo/wiki/raw/LINK"></video>`, out) + + out = render(`<video src="/LINK">`, false, markup.Links{Base: "/test-owner/test-repo"}) + assert.Equal(t, `<video src="/LINK"></video>`, out) } func Test_ParseClusterFuzz(t *testing.T) { |