Skip to content

Commit 8d21c66

Browse files
sathisalexjorgef
sathis
authored andcommitted
Dont auto generate last build date
1 parent b04e177 commit 8d21c66

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

lib/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ function generateXML (data){
3939
channel.push({ image: [ {url: data.image_url}, {title: data.title}, {link: data.site_url} ] });
4040
}
4141
channel.push({ generator: data.generator });
42-
channel.push({ lastBuildDate: new Date().toUTCString() });
42+
if (!data.omitBuildDate) {
43+
channel.push({ lastBuildDate: new Date().toUTCString() });
44+
}
4345

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

163166
this.item = function (options) {
164167
options = options || {};

test/expectedOutput/omitBuildDate.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?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">
2+
<channel>
3+
<title><![CDATA[title]]></title>
4+
<description><![CDATA[description]]></description>
5+
<link>http://example.com</link>
6+
<generator>RSS for Node</generator>
7+
<atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/>
8+
</channel>
9+
</rss>

test/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,17 @@ test('custom namespaces', function(t) {
336336

337337
t.equal(feed.xml({indent: true}), expectedOutput.customNamespaces);
338338
});
339+
340+
test('omit build date', function(t) {
341+
t.plan(1);
342+
343+
var feed = new RSS({
344+
title: 'title',
345+
description: 'description',
346+
feed_url: 'http://example.com/rss.xml',
347+
site_url: 'http://example.com',
348+
omitBuildDate: true
349+
});
350+
351+
t.equal(feed.xml({indent: true}), expectedOutput.omitBuildDate);
352+
});

0 commit comments

Comments
 (0)