-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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}` } }
}
👀 |
I tried to put as many of the changes in #120 |
Three additions and one fix: