1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

When detecting the format, detect its version as well

There is no need to detect the format and then the version when both can be
done at the same time.

Add a benchmark as well, on large and small atom and rss files.
This commit is contained in:
jvoisin 2024-03-12 13:11:56 +01:00 committed by Frédéric Guillot
parent 688b73b7ae
commit 45d486b919
12 changed files with 3608 additions and 160 deletions

View file

@ -19,10 +19,11 @@ var ErrFeedFormatNotDetected = errors.New("parser: unable to detect feed format"
// ParseFeed analyzes the input data and returns a normalized feed object.
func ParseFeed(baseURL string, r io.ReadSeeker) (*model.Feed, error) {
r.Seek(0, io.SeekStart)
switch DetectFeedFormat(r) {
format, version := DetectFeedFormat(r)
switch format {
case FormatAtom:
r.Seek(0, io.SeekStart)
return atom.Parse(baseURL, r)
return atom.Parse(baseURL, r, version)
case FormatRSS:
r.Seek(0, io.SeekStart)
return rss.Parse(baseURL, r)