mirror of
https://github.com/miniflux/v2.git
synced 2025-09-05 18:41:01 +00:00
Proxify image enclosures
This commit is contained in:
parent
1a90c059e7
commit
fb2a73c91e
9 changed files with 56 additions and 30 deletions
|
@ -5,7 +5,7 @@ import "testing"
|
|||
func TestGetAbsoluteURLWithAbsolutePath(t *testing.T) {
|
||||
expected := `https://example.org/path/file.ext`
|
||||
input := `/path/file.ext`
|
||||
output, err := GetAbsoluteURL("https://example.org/folder/", input)
|
||||
output, err := AbsoluteURL("https://example.org/folder/", input)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -19,7 +19,7 @@ func TestGetAbsoluteURLWithAbsolutePath(t *testing.T) {
|
|||
func TestGetAbsoluteURLWithRelativePath(t *testing.T) {
|
||||
expected := `https://example.org/folder/path/file.ext`
|
||||
input := `path/file.ext`
|
||||
output, err := GetAbsoluteURL("https://example.org/folder/", input)
|
||||
output, err := AbsoluteURL("https://example.org/folder/", input)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -33,7 +33,7 @@ func TestGetAbsoluteURLWithRelativePath(t *testing.T) {
|
|||
func TestGetAbsoluteURLWithRelativePaths(t *testing.T) {
|
||||
expected := `https://example.org/path/file.ext`
|
||||
input := `path/file.ext`
|
||||
output, err := GetAbsoluteURL("https://example.org/folder", input)
|
||||
output, err := AbsoluteURL("https://example.org/folder", input)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -47,7 +47,7 @@ func TestGetAbsoluteURLWithRelativePaths(t *testing.T) {
|
|||
func TestWhenInputIsAlreadyAbsolute(t *testing.T) {
|
||||
expected := `https://example.org/path/file.ext`
|
||||
input := `https://example.org/path/file.ext`
|
||||
output, err := GetAbsoluteURL("https://example.org/folder/", input)
|
||||
output, err := AbsoluteURL("https://example.org/folder/", input)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -61,7 +61,7 @@ func TestWhenInputIsAlreadyAbsolute(t *testing.T) {
|
|||
func TestGetAbsoluteURLWithProtocolRelative(t *testing.T) {
|
||||
expected := `https://static.example.org/path/file.ext`
|
||||
input := `//static.example.org/path/file.ext`
|
||||
output, err := GetAbsoluteURL("https://www.example.org/", input)
|
||||
output, err := AbsoluteURL("https://www.example.org/", input)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -75,7 +75,7 @@ func TestGetAbsoluteURLWithProtocolRelative(t *testing.T) {
|
|||
func TestGetRootURL(t *testing.T) {
|
||||
expected := `https://example.org/`
|
||||
input := `https://example.org/path/file.ext`
|
||||
output := GetRootURL(input)
|
||||
output := RootURL(input)
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Unexpected output, got "%s" instead of "%s"`, output, expected)
|
||||
|
@ -85,7 +85,7 @@ func TestGetRootURL(t *testing.T) {
|
|||
func TestGetRootURLWithProtocolRelativePath(t *testing.T) {
|
||||
expected := `https://static.example.org/`
|
||||
input := `//static.example.org/path/file.ext`
|
||||
output := GetRootURL(input)
|
||||
output := RootURL(input)
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Unexpected output, got "%s" instead of "%s"`, output, expected)
|
||||
|
@ -105,3 +105,13 @@ func TestIsHTTPS(t *testing.T) {
|
|||
t.Error("Unable to recognize malformed URL")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDomain(t *testing.T) {
|
||||
expected := `static.example.org`
|
||||
input := `http://static.example.org/`
|
||||
output := Domain(input)
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Unexpected output, got "%s" instead of "%s"`, output, expected)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue