Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
return value;
};
function wrapDescription(rule) {
return $ => {
let value = rule($);
if (typeof value !== 'string') {
return undefined;
}
value = value.trim();
value = value.replace(/^[A-Z\s]+\s+[-—–]\s+/, '');
return trimLength(value, 160);
};
}
return {
...Metascraper.RULES,
url: () => url.href,
origin: () => url.origin,
description: [
...Metascraper.RULES.description,
wrapDescription($ =>
$('p')
.first()
.text(),
),
],
favicon: () => ({
url: `https://res.cloudinary.com/demo/image/fetch/${url.origin}/favicon.ico`,
width: 32,
height: 32,
}),
extract: $ =>
return $ => {
let value = rule($);
if (typeof value !== 'string') {
return undefined;
}
value = value.trim();
value = value.replace(/^[A-Z\s]+\s+[-—–]\s+/, '');
return trimLength(value, 160);
};
}
return {
...Metascraper.RULES,
url: () => url.href,
origin: () => url.origin,
description: [
...Metascraper.RULES.description,
wrapDescription($ =>
$('p')
.first()
.text(),
),
],
favicon: () => ({
url: `https://res.cloudinary.com/demo/image/fetch/${url.origin}/favicon.ico`,
width: 32,
height: 32,
}),
extract: $ =>
$('p')
.first()
.text(),
image: [