1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

Allow only absolute URLs in comments URL

Some feeds are using invalid URLs (random text).
This commit is contained in:
Frédéric Guillot 2020-01-04 15:18:24 -08:00
parent 8cebd985a2
commit bf632fad2e
6 changed files with 105 additions and 2 deletions

View file

@ -11,6 +11,15 @@ import (
"strings"
)
// IsAbsoluteURL returns true if the link is absolute.
func IsAbsoluteURL(link string) bool {
u, err := url.Parse(link)
if err != nil {
return false
}
return u.IsAbs()
}
// AbsoluteURL converts the input URL as absolute URL if necessary.
func AbsoluteURL(baseURL, input string) (string, error) {
if strings.HasPrefix(input, "//") {