Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
fix(plugin): banner id generator
Browse files Browse the repository at this point in the history
  • Loading branch information
kisenka committed Nov 20, 2017
1 parent 2f3ca9e commit aa20fa3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/process-banners.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ function processBanners(banners) {
*/
function generateId(banner) {
const fields = ['entry', 'id', 'start', 'end', 'locations', 'countries'];
const data = fields.reduce((field, acc) => {
const data = fields.reduce((acc, field) => {
if (typeof banner[field] !== 'undefined') {
acc[field] = banner[field];
}
return acc;
}, {});

const stringified = JSON.stringify(data);
return crypto.createHash('md5').update(stringified).digest('hex');
const id = crypto.createHash('md5').update(stringified).digest('hex');
return id;
}

module.exports = processBanners;

0 comments on commit aa20fa3

Please sign in to comment.