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

Option to specify CDATA wrapper for content #28

Closed
wants to merge 2 commits into from

Conversation

tmshv
Copy link

@tmshv tmshv commented Feb 9, 2014

No description provided.

@tmshv tmshv mentioned this pull request Feb 9, 2014
@dylang
Copy link
Owner

dylang commented Sep 26, 2014

I like your change, and how you cleaned up the formatting. Can somebody else review this change and give a 👍 if it looks good?

@Mithgol
Copy link
Contributor

Mithgol commented Sep 27, 2014

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
Copy link

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();
    });

@dylang
Copy link
Owner

dylang commented Feb 8, 2015

Closing in favor of #38. Thanks for getting this started @tmshv!

@dylang dylang closed this Feb 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants