-
Notifications
You must be signed in to change notification settings - Fork 132
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
Option to specify CDATA wrapper for content #28
Conversation
I like your change, and how you cleaned up the formatting. Can somebody else review this change and give a 👍 if it looks good? |
This change seems fine, but some additional changes in README might become necessary. |
@@ -27,6 +27,7 @@ function RSS (options, items) { | |||
this.ttl = options.ttl; | |||
//option to return feed as GeoRSS is set automatically if feed.lat/long is used | |||
this.geoRSS = options.geoRSS || false; | |||
this.cdata = options.cdata || true; //will wrap content to CDATA |
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 will result in options.cdata = true
when cdata is passed in as false
, so CDATA wrapping always occurs.
Add this to the bottom of the tests to expose the bug:
it('should wrap elements with CDATA', function(done) {
var feed = new RSS({
title: 'title',
description: 'description',
feed_url: 'http://example.com/rss.xml',
site_url: 'http://example.com',
cdata: true
});
var expectedResult = '<?xml version="1.0" encoding="UTF-8"?>\n'+
'<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">'+
'<channel>'+
'<title><![CDATA[title]]></title>'+
'<description><![CDATA[description]]></description>'+
'<link>http://example.com</link>'+
'<generator>RSS for Node</generator>'+
'<lastBuildDate>' + new Date().toUTCString() +'</lastBuildDate>'+
'<atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/>'+
'</channel>'+
'</rss>';
var result = feed.xml();
expect(result).to.equal(expectedResult);
done();
});
it('should wrap not elements with CDATA', function(done) {
var feed = new RSS({
title: 'title',
description: 'description',
feed_url: 'http://example.com/rss.xml',
site_url: 'http://example.com',
cdata: false
});
var expectedResult = '<?xml version="1.0" encoding="UTF-8"?>\n'+
'<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">'+
'<channel>'+
'<title>title</title>'+
'<description>description</description>'+
'<link>http://example.com</link>'+
'<generator>RSS for Node</generator>'+
'<lastBuildDate>' + new Date().toUTCString() +'</lastBuildDate>'+
'<atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/>'+
'</channel>'+
'</rss>';
var result = feed.xml();
expect(result).to.equal(expectedResult);
done();
});
No description provided.