added `parseTagList`

master
rob 2 years ago
parent 2c13b997bf
commit 43b340790a

@ -7,6 +7,8 @@
const path = require('path');
const pug = require('pug');
const striptags = require('striptags');
const { SiteLog } = require(path.join(__dirname, 'site-log'));
const { SiteAsync } = require(path.join(__dirname, 'site-async'));
@ -102,6 +104,25 @@ class SiteCommon extends Events {
}, options);
return pug.compileFileClient(scriptFile, options);
}
parseTagList (tagList, options) {
options = Object.assign({
lowercase: true,
filter: [ ],
}, options);
return tagList
.split(',')
.map((metric) => {
metric = striptags(metric.trim());
return options.lowercase ? metric.toLowerCase() : metric;
})
.filter((metric) => {
return (typeof metric === 'string') &&
(metric.length > 0) &&
!options.filter.includes(metric.toLowerCase())
;
});
}
}
module.exports.SiteCommon = SiteCommon;
Loading…
Cancel
Save