dotandimet / Mojo-Feed

Mojo::DOM based Feed Parser
Other
4 stars 1 forks source link

Check if feed is valid #12

Closed mdom closed 6 years ago

mdom commented 6 years ago

Maybe we were a little bit too lazy. Without this change any successful http request will result in a valid Mojo::Feed object.

dotandimet commented 6 years ago

Lol. I noticed this in several places when porting stuff from the plugin version; previously parse_feed() returned undef or a hashref, now we always return an object. In some places I checked if a field is defined (i.e if ($feed->description) { ... }) I'll switch to using is_valid throughout.

dotandimet commented 6 years ago

Related: should parse return undef if the feed isn't valid? Currently it will return a Mojo::Feed object which stringifies to whatever XML/HTML it was given (and returns false if is_valid is called).

dotandimet commented 6 years ago

My opinion is "yes", i.e, you could construct an invalid Mojo::Feed object with Mojo::Feed->new(body => 'crap'), but Mojo::Feed::Reader::parse shouldn't give you one.

mdom commented 6 years ago

That sounds reasonable!