<commit_before>/**
 *
 */



/**
 *
 */
export default function metaTagsExtractor(pattern) {
	return async function extractMetaTags(req, res) {

	}
}<commit_msg>Implemented meta tags extractor<commit_after>/**
 *
 */
import cheerio from 'cheerio';



/**
 *
 */
function extractProperties(pattern, html) {
	const $ = cheerio.load(html);
	const metas = $('meta', 'head');
	const props = {};

	metas.each((i, meta) => {
		const name = $(meta).attr('property');

		if (!name || !name.match(pattern)) {
			return;
		}

		if (!props[name]) {
			props[name] = [];
		}

		props[name].push(
			$(meta).attr('content')
		);
	});

	return props;
}

/**
 *
 */
export default function metaTagsExtractor(pattern) {
	return async function extractMetaTags(req, res) {
		const html = await req.body();
		const props = extractProperties(pattern, html);

		return res.withProps(props);
	}
}
{'fraction_non_alphanumeric': 0.17983963344788087, 'fraction_numerical': 0.0, 'mean_word_length': 3.6989247311827955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6138258', 'n_tokens_mistral': 321, 'n_tokens_neox': 291, 'n_words': 64}