rss-parser
Advanced tools
Comparing version 3.10.0 to 3.11.0
@@ -46,2 +46,10 @@ import { Options } from 'xml2js'; | ||
export interface PaginationLinks { | ||
self?: string; | ||
first?: string; | ||
next?: string; | ||
last?: string; | ||
prev?: string; | ||
} | ||
export interface Output<U> { | ||
@@ -53,2 +61,3 @@ image?: { | ||
}, | ||
paginationLinks?: PaginationLinks; | ||
link?: string; | ||
@@ -55,0 +64,0 @@ title?: string; |
@@ -198,2 +198,6 @@ "use strict"; | ||
} | ||
const paginationLinks = this.generatePaginationLinks(channel); | ||
if (Object.keys(paginationLinks).length) { | ||
feed.paginationLinks = paginationLinks; | ||
} | ||
utils.copyFromXML(channel, feed, feedFields); | ||
@@ -313,4 +317,27 @@ feed.items = items.map(xmlItem => this.parseItemRss(xmlItem, itemFields)); | ||
} | ||
/** | ||
* Generates a pagination object where the rel attribute is the key and href attribute is the value | ||
* { self: 'self-url', first: 'first-url', ... } | ||
* | ||
* @access private | ||
* @param {Object} channel parsed XML | ||
* @returns {Object} | ||
*/ | ||
generatePaginationLinks(channel) { | ||
if (!channel['atom:link']) { | ||
return {}; | ||
} | ||
const paginationRelAttributes = ['self', 'first', 'next', 'prev', 'last']; | ||
return channel['atom:link'].reduce((paginationLinks, link) => { | ||
if (!link.$ || !paginationRelAttributes.includes(link.$.rel)) { | ||
return paginationLinks; | ||
} | ||
paginationLinks[link.$.rel] = link.$.href; | ||
return paginationLinks; | ||
}, {}); | ||
} | ||
} | ||
module.exports = Parser; |
{ | ||
"name": "rss-parser", | ||
"version": "3.10.0", | ||
"version": "3.11.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "types": "index.d.ts", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1822129
11749