|
|
@@ -124,10 +124,9 @@ func (f *subscriptionFinder) FindSubscriptions(websiteURL, rssBridgeURL string,
|
|
|
|
|
|
func (f *subscriptionFinder) findSubscriptionsFromWebPage(websiteURL, contentType string, body io.Reader) (Subscriptions, *locale.LocalizedErrorWrapper) {
|
|
|
queries := map[string]string{
|
|
|
- "link[type='application/rss+xml']": parser.FormatRSS,
|
|
|
- "link[type='application/atom+xml']": parser.FormatAtom,
|
|
|
- "link[type='application/json']": parser.FormatJSON,
|
|
|
- "link[type='application/feed+json']": parser.FormatJSON,
|
|
|
+ "link[type='application/rss+xml']": parser.FormatRSS,
|
|
|
+ "link[type='application/atom+xml']": parser.FormatAtom,
|
|
|
+ "link[type='application/json'], link[type='application/feed+json']": parser.FormatJSON,
|
|
|
}
|
|
|
|
|
|
htmlDocumentReader, err := encoding.NewCharsetReader(body, contentType)
|
|
|
@@ -154,24 +153,24 @@ func (f *subscriptionFinder) findSubscriptionsFromWebPage(websiteURL, contentTyp
|
|
|
subscription := new(subscription)
|
|
|
subscription.Type = kind
|
|
|
|
|
|
- if title, exists := s.Attr("title"); exists {
|
|
|
- subscription.Title = title
|
|
|
+ if feedURL, exists := s.Attr("href"); exists && feedURL != "" {
|
|
|
+ subscription.URL, err = urllib.AbsoluteURL(websiteURL, feedURL)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return // without an url, there can be no subscription.
|
|
|
}
|
|
|
|
|
|
- if feedURL, exists := s.Attr("href"); exists {
|
|
|
- if feedURL != "" {
|
|
|
- subscription.URL, err = urllib.AbsoluteURL(websiteURL, feedURL)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
+ if title, exists := s.Attr("title"); exists {
|
|
|
+ subscription.Title = title
|
|
|
}
|
|
|
|
|
|
if subscription.Title == "" {
|
|
|
subscription.Title = subscription.URL
|
|
|
}
|
|
|
|
|
|
- if subscription.URL != "" && !subscriptionURLs[subscription.URL] {
|
|
|
+ if !subscriptionURLs[subscription.URL] {
|
|
|
subscriptionURLs[subscription.URL] = true
|
|
|
subscriptions = append(subscriptions, subscription)
|
|
|
}
|