From 4ee6e571116528ab2bea0fd9b48241c238c19a32 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 23 Dec 2021 10:59:21 +0000 Subject: [PATCH] let feedparser accept simple xml headers to close #867 --- social/feedparser/32-feedparse.js | 10 +++++----- social/feedparser/package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/social/feedparser/32-feedparse.js b/social/feedparser/32-feedparse.js index 6e8482ee..aea5fef0 100644 --- a/social/feedparser/32-feedparse.js +++ b/social/feedparser/32-feedparse.js @@ -10,19 +10,19 @@ module.exports = function(RED) { this.url = n.url; if (n.interval > 35790) { this.warn(RED._("feedparse.errors.invalidinterval")) } this.interval = (parseInt(n.interval)||15) * 60000; - var node = this; this.interval_id = null; this.seen = {}; + var node = this; var parsedUrl = url.parse(this.url); if (!(parsedUrl.host || (parsedUrl.hostname && parsedUrl.port)) && !parsedUrl.isUnix) { - this.error(RED._("feedparse.errors.invalidurl")); + node.error(RED._("feedparse.errors.invalidurl")); } else { var getFeed = function() { var req = request(node.url, {timeout:10000, pool:false}); //req.setMaxListeners(50); req.setHeader('user-agent', 'Mozilla/5.0 (Node-RED)'); - req.setHeader('accept', 'application/rss+xml,text/html,application/xhtml+xml'); + req.setHeader('accept', 'application/rss+xml,text/html,application/xhtml+xml,application/xml'); var feedparser = new FeedParser(); @@ -53,11 +53,11 @@ module.exports = function(RED) { feedparser.on('meta', function (meta) {}); feedparser.on('end', function () {}); }; - this.interval_id = setInterval(function() { getFeed(); }, node.interval); + node.interval_id = setInterval(function() { getFeed(); }, node.interval); getFeed(); } - this.on("close", function() { + node.on("close", function() { if (this.interval_id != null) { clearInterval(this.interval_id); } diff --git a/social/feedparser/package.json b/social/feedparser/package.json index 6517f382..ca3d75cc 100644 --- a/social/feedparser/package.json +++ b/social/feedparser/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-feedparser", - "version": "0.2.1", + "version": "0.2.2", "description": "A Node-RED node to get RSS Atom feeds.", "dependencies": { "feedparser": "^2.2.10",