@@ 21,11 21,11 @@ const (
FEED_GEMINI = "gemini"
)
-func fetchGemini(ctx context.Context, url *url.URL) (*rss.Feed, string, error) {
+func fetchGemini(ctx context.Context, remoteURL *url.URL) (*rss.Feed, string, error) {
client := &gemini.Client{}
tctx, cancel := context.WithTimeout(ctx, 10 * time.Second)
defer cancel()
- resp, err := client.Get(tctx, url.String())
+ resp, err := client.Get(tctx, remoteURL.String())
if err != nil {
return nil, "", err
}
@@ 45,7 45,7 @@ func fetchGemini(ctx context.Context, url *url.URL) (*rss.Feed, string, error) {
switch mimetype {
case "text/gemini":
var feed rss.Feed
- feed.Link = url.String()
+ feed.Link = remoteURL.String()
text, err := gemini.ParseText(resp.Body)
if err != nil {
return nil, "", err
@@ 65,10 65,15 @@ func fetchGemini(ctx context.Context, url *url.URL) (*rss.Feed, string, error) {
if err != nil {
continue
}
+ link, err := url.Parse(line.URL)
+ if err != nil {
+ continue
+ }
+ link = remoteURL.ResolveReference(link)
item := &rss.Item{}
item.Title = strings.TrimLeft(line.Name[10:], ": ")
item.Date = date
- item.Link = line.URL
+ item.Link = link.String()
feed.Items = append(feed.Items, item)
}
}