MM-12009 Resolve relative links in posts as the web app does (#9896)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9730b46bca
Коммит
1607d18e55
@@ -994,6 +994,47 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveMetadataURL(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
Name string
|
||||
RequestURL string
|
||||
SiteURL string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Name: "with HTTPS",
|
||||
RequestURL: "https://example.com/file?param=1",
|
||||
Expected: "https://example.com/file?param=1",
|
||||
},
|
||||
{
|
||||
Name: "with HTTP",
|
||||
RequestURL: "http://example.com/file?param=1",
|
||||
Expected: "http://example.com/file?param=1",
|
||||
},
|
||||
{
|
||||
Name: "with FTP",
|
||||
RequestURL: "ftp://example.com/file?param=1",
|
||||
Expected: "ftp://example.com/file?param=1",
|
||||
},
|
||||
{
|
||||
Name: "relative to root",
|
||||
RequestURL: "/file?param=1",
|
||||
SiteURL: "https://mattermost.example.com:123",
|
||||
Expected: "https://mattermost.example.com:123/file?param=1",
|
||||
},
|
||||
{
|
||||
Name: "relative to root with subpath",
|
||||
RequestURL: "/file?param=1",
|
||||
SiteURL: "https://mattermost.example.com:123/subpath",
|
||||
Expected: "https://mattermost.example.com:123/file?param=1",
|
||||
},
|
||||
} {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
assert.Equal(t, resolveMetadataURL(test.RequestURL, test.SiteURL), test.Expected)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseLinkMetadata(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user