mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-25 05:29:20 +00:00
handle missing feed title
This commit is contained in:
parent
dc1123e868
commit
b4ecb30b9d
@ -2,6 +2,7 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"html"
|
"html"
|
||||||
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Feed struct {
|
type Feed struct {
|
||||||
@ -17,7 +18,19 @@ type Feed struct {
|
|||||||
|
|
||||||
func (s *Storage) CreateFeed(title, description, link, feedLink string, folderId *int64) *Feed {
|
func (s *Storage) CreateFeed(title, description, link, feedLink string, folderId *int64) *Feed {
|
||||||
title = html.UnescapeString(title)
|
title = html.UnescapeString(title)
|
||||||
if len(title) == 0 {
|
// WILD: fallback to `feed.link` -> `feed.feed_link` -> "<???>" if title is missing
|
||||||
|
if title == "" {
|
||||||
|
title = link
|
||||||
|
// use domain if possible
|
||||||
|
linkUrl, err := url.Parse(link)
|
||||||
|
if err != nil && len(linkUrl.Host) > 0 && len(linkUrl.Path) <= 1 {
|
||||||
|
title = linkUrl.Host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if title == "" {
|
||||||
|
title = feedLink
|
||||||
|
}
|
||||||
|
if title == "" {
|
||||||
title = "<???>"
|
title = "<???>"
|
||||||
}
|
}
|
||||||
result, err := s.db.Exec(`
|
result, err := s.db.Exec(`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user