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

fix handling of 'image' parameter #54

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/feed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/feed.js.map

Large diffs are not rendered by default.

118 changes: 59 additions & 59 deletions package.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
{
"name": "feed",
"version": "1.0.2",
"description": "Feed is a RSS and Atom feed generator for Node.js, making content syndication simple and intuitive!",
"homepage": "http://projets.jpmonette.net/en/feed",
"author": "Jean-Philippe Monette <contact@jpmonette.net>",
"contributors": [
{
"name": "Pierre Galvez",
"email": "contact@pierre-galvez.fr"
}
],
"license": "MIT",
"main": "lib/feed.js",
"scripts": {
"build": "rm -rf lib/ && mkdir lib && babel -d lib/ src/ --ignore **/*.spec.js -s",
"prepublish": "npm run build",
"test": "export NODE_ENV=test && jest",
"test-travis": "export NODE_ENV=test && jest"
},
"jest": {
"verbose": true,
"collectCoverage": true,
"collectCoverageFrom": [
"**/src/*.{js}"
],
"testMatch": [
"**/*.spec.js"
]
},
"keywords": [
"rss",
"atom",
"feed",
"syndication",
"xml",
"wrapper",
"blog"
],
"dependencies": {
"xml": ">= 0.0.5"
},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-preset-latest": "^6.24.0",
"coveralls": "^2.13.0",
"jest": "^19.0.2"
},
"engines": {
"node": ">=0.4.0"
},
"bugs": {
"url": "https://github.com/jpmonette/feed/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/jpmonette/feed.git"
}
}
{
"name": "feed",
"version": "1.0.2",
"description": "Feed is a RSS and Atom feed generator for Node.js, making content syndication simple and intuitive!",
"homepage": "http://projets.jpmonette.net/en/feed",
"author": "Jean-Philippe Monette <contact@jpmonette.net>",
"contributors": [
{
"name": "Pierre Galvez",
"email": "contact@pierre-galvez.fr"
}
],
"license": "MIT",
"main": "lib/feed.js",
"scripts": {
"build": "rm -rf lib/ && mkdir lib && babel -d lib/ src/ --ignore **/*.spec.js -s",
"prepublish": "npm run build",
"test": "export NODE_ENV=test && jest",
"test-travis": "export NODE_ENV=test && jest"
},
"jest": {
"verbose": true,
"collectCoverage": true,
"collectCoverageFrom": [
"**/src/*.{js}"
],
"testMatch": [
"**/*.spec.js"
]
},
"keywords": [
"rss",
"atom",
"feed",
"syndication",
"xml",
"wrapper",
"blog"
],
"dependencies": {
"xml": ">= 0.0.5"
},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-preset-latest": "^6.24.0",
"coveralls": "^2.13.0",
"jest": "^19.0.2"
},
"engines": {
"node": ">=0.4.0"
},
"bugs": {
"url": "https://github.com/jpmonette/feed/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/jpmonette/feed.git"
}
}
10 changes: 8 additions & 2 deletions src/feed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import xml from 'xml'
import mime from 'mime-types'

const GENERATOR = 'Feed for Node.js'
const DOCTYPE = '<?xml version="1.0" encoding="utf-8"?>\n'
Expand Down Expand Up @@ -352,8 +353,13 @@ class Feed {
})
}

if(item.image) {
item.push({ enclosure: [{ _attr: { url: entry.image } }] });
if(entry.image) {
let attr = { url: entry.image };
let contentType = mime.lookup(entry.image);
if(contentType && contentType.indexOf('image/')==0) {
attr.type = contentType;
}
item.push({ enclosure: [{ _attr: attr }] });
}

channel.push({ item });
Expand Down
2 changes: 2 additions & 0 deletions src/feed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ test('it should generate an RSS 2.0 feed', () => {
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<author>janedoe@example.com (Jane Doe)</author>
<enclosure url=\"https://example.com/hello-world.jpg\" type=\"image/jpeg\">
</enclosure>
</item>
</channel>
</rss>`;
Expand Down