Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ttl, language and categories to RSS. Fixed item image RSS. #64

Closed
wants to merge 2 commits into from
Closed

Added ttl, language and categories to RSS. Fixed item image RSS. #64

wants to merge 2 commits into from

Conversation

fabionolasco
Copy link

Three additions and one fix:

  1. Added TTL property on RSS
  2. Added Language property on RSS
  3. Added Categories property on RSS
  4. Fixed item's image property on RSS

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.6%) to 86.911% when pulling 62df226 on fabionolasco:fn/rss-updates into 3f46291 on jpmonette:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.9%) to 85.641% when pulling 24ac503 on fabionolasco:fn/rss-updates into 3f46291 on jpmonette:master.

Copy link

@aslafy-z aslafy-z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, here's some points to review.
It's also missing it's typescript types definitions edits from there: https://github.com/jpmonette/feed/blob/master/src/types/index.ts.

You also need to update the tests to add these fields.

Finally, you may want to update other feed implementations such as Atom and JSON feeds with equivalent values.

@@ -326,7 +334,11 @@ class Feed {
}

if(entry.guid) {
item.push({ guid: entry.guid });
if (entry.guid.indexOf('http') === -1) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to use startsWith instead of indexOf.

@@ -279,7 +287,7 @@ class Feed {
* Feed URL
* http://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html
*/
const atomLink = options.feed || (options.feedLinks && options.feedLinks.atom);
const atomLink = options.feed || (options.feedLinks && options.feedLinks.rss);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reverted to use options.feedLinks.atom.

if(item.image) {
item.push({ enclosure: [{ _attr: { url: entry.image } }] });
if(entry.image) {
var type = entry.image.split('.').pop().replace('jpg', 'jpeg');
Copy link

@aslafy-z aslafy-z Nov 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use const/let instead of var.
Also, this method to get the extension works only if the links are clean (eg: no querystring nor hashstring).
It wont work for something like this: http://my.image.server/bla.jpg?key=foobar. You may want to use this instead: URL() (compatibility here https://caniuse.com/#feat=url)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this worked for me

if (entry.image) {
      const type = new URL(entry.image).pathname.split('.').slice(-1)[0]
      item.enclosure = { _attributes: { url: entry.image, length: 0, type: `image/${type}` } }
    }

@hameltomor
Copy link

👀

@decebal
Copy link
Contributor

decebal commented May 20, 2020

I tried to put as many of the changes in #120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants