replaceAll is node15+

This commit is contained in:
Wouter Groeneveld 2021-03-17 18:54:07 +01:00
parent eac72b0b7b
commit 8926e953b7
1 changed files with 2 additions and 4 deletions

View File

@ -12,10 +12,8 @@ const parseOpts = {
function collectHrefsFromDescription(description) {
// first thought: use parser.parse() and traverse recursively. turned out to be way too slow.
const x = description.match(/href="([^"]*")/g)
console.log(x)
const links = x
.map(match => match.replace("href=", "").replaceAll("\"", ""))
const links = description.match(/href="([^"]*")/g)
.map(match => match.replace("href=", "").replace(/\"/g, ""))
.filter(match => !(/\.(gif|zip|rar|bz2|gz|7z|jpe?g|tiff?|png|webp|bmp)$/i).test(match))
.filter(match => !config.disallowedWebmentionDomains.some(domain => match.indexOf(domain) >= 0))
return [...new Set(links)]