Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function addSrcSetDependencies(srcset: string) {
const newSources = [];
srcset.split(',').forEach(source => {
const pair = source.trim().split(' ');
if (pair.length === 0) return;
pair[0] = addDependency(pair[0]);
newSources.push(pair.join(' '));
});
return newSources.join(',');
}
const res = parse(code, { lowerCaseAttributeNames: true });
res.walk = api.walk;
res.match = api.match;
res.walk(node => {
if (node == null) {
return node;
}
if (node.attrs) {
if (node.tag === 'meta') {
if (
!Object.keys(node.attrs).some(attr => {
const values = META[attr];
return values && values.includes(node.attrs[attr]);
})
) {
return node;
}
opts.singleTags = opts.singleTags.filter((tag) => {
let hasContent = false;
api.match.call(tree, { tag }, (node) => {
if (typeof node.content !== 'undefined' && !hasContent) {
hasContent = true;
}
return node;
});
return !hasContent;
});
async parse(code) {
let res = await posthtmlTransform.parse(code, this);
res.walk = api.walk;
res.match = api.match;
return res;
}
async parse(code) {
let res = await posthtmlTransform.parse(code, this);
res.walk = api.walk;
res.match = api.match;
return res;
}