ori-repro-earlier-bug/parseHtml.js

15 lines
391 B
JavaScript

import {fromHtml} from 'hast-util-from-html';
import {visit} from 'unist-util-visit';
export default async function(value) {
const tree = fromHtml(value);
const links = [];
visit(tree, [{tagName: 'link'}, {tagName: 'img'}], function(node) {
links.push(node);
})
const hrefs = links.map(link => link.properties.href || link.properties.src)
return hrefs;
// return tree;
}