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

Dont auto generate last build date #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function generateXML (data){
channel.push({ image: [ {url: data.image_url}, {title: data.title}, {link: data.site_url} ] });
}
channel.push({ generator: data.generator });
channel.push({ lastBuildDate: new Date().toUTCString() });
if (!data.omitBuildDate) {
channel.push({ lastBuildDate: new Date().toUTCString() });
}

ifTruePush(data.feed_url, channel, { 'atom:link': { _attr: { href: data.feed_url, rel: 'self', type: 'application/rss+xml' } } });
ifTruePush(data.author, channel, { 'author': { _cdata: data.author } });
Expand Down Expand Up @@ -159,6 +161,7 @@ function RSS (options, items) {
this.custom_namespaces = options.custom_namespaces || {};
this.custom_elements = options.custom_elements || [];
this.items = items || [];
this.omitBuildDate = options.omitBuildDate || false;

this.item = function (options) {
options = options || {};
Expand Down
9 changes: 9 additions & 0 deletions test/expectedOutput/omitBuildDate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><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>
<atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/>
</channel>
</rss>
14 changes: 14 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,17 @@ test('custom namespaces', function(t) {

t.equal(feed.xml({indent: true}), expectedOutput.customNamespaces);
});

test('omit build date', function(t) {
t.plan(1);

var feed = new RSS({
title: 'title',
description: 'description',
feed_url: 'http://example.com/rss.xml',
site_url: 'http://example.com',
omitBuildDate: true
});

t.equal(feed.xml({indent: true}), expectedOutput.omitBuildDate);
});
Loading