diff options
author | Frédéric Guillot <fred@miniflux.net> | 2020-01-04 15:18:24 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2020-01-04 15:54:16 -0800 |
commit | bf632fad2e19e9ece4db5957f05727f373541917 (patch) | |
tree | 34c8f90d920f55892c10a25bba47f07c580dfe74 /url/url_test.go | |
parent | 8cebd985a267f6fbcc363672ca81780dd5407eff (diff) |
Allow only absolute URLs in comments URL
Some feeds are using invalid URLs (random text).
Diffstat (limited to 'url/url_test.go')
-rw-r--r-- | url/url_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/url/url_test.go b/url/url_test.go index 56b6e13..ea488cf 100644 --- a/url/url_test.go +++ b/url/url_test.go @@ -6,6 +6,21 @@ package url // import "miniflux.app/url" import "testing" +func TestIsAbsoluteURL(t *testing.T) { + scenarios := map[string]bool{ + "https://example.org/file.pdf": true, + "magnet:?xt.1=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C&xt.2=urn:sha1:TXGCZQTH26NL6OUQAJJPFALHG2LTGBC7": true, + "invalid url": false, + } + + for input, expected := range scenarios { + actual := IsAbsoluteURL(input) + if actual != expected { + t.Errorf(`Unexpected result, got %v instead of %v for %q`, actual, expected, input) + } + } +} + func TestAbsoluteURL(t *testing.T) { scenarios := [][]string{ []string{"https://example.org/path/file.ext", "https://example.org/folder/", "/path/file.ext"}, |