mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
bb8cf6001e
refs https://github.com/TryGhost/Team/issues/828 - When detecting email segments and later creating a member filter out of this data we only care about unique segments otherwise we'd be creating multiple batches with the same segment filter
15 lines
361 B
JavaScript
15 lines
361 B
JavaScript
const cheerio = require('cheerio');
|
|
|
|
const getSegmentsFromHtml = (html) => {
|
|
const $ = cheerio.load(html);
|
|
|
|
const allSegments = $('[data-gh-segment]')
|
|
.get()
|
|
.map(el => el.attribs['data-gh-segment']);
|
|
|
|
// only return unique elements
|
|
return [...new Set(allSegments)];
|
|
};
|
|
|
|
module.exports.getSegmentsFromHtml = getSegmentsFromHtml;
|