From eac58883fd56d2e2d3dd2cbb5b8b01259b1896df Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 29 Mar 2024 19:29:50 -0300 Subject: external-links: matchingDescriptors syntax cleanup --- src/util/external-links.js | 49 +++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'src/util') diff --git a/src/util/external-links.js b/src/util/external-links.js index c5f5139..6d993ee 100644 --- a/src/util/external-links.js +++ b/src/util/external-links.js @@ -563,28 +563,33 @@ export function getMatchingDescriptorsForExternalLink(url, descriptors, { const matchingDescriptors = descriptors - .filter(({match}) => { - if (match.domain) return compareDomain(match.domain); - if (match.domains) return match.domains.some(compareDomain); - return false; - }) - .filter(({match}) => { - if (Array.isArray(match.context)) - return match.context.some(c => contextArray.includes(c)); - if (match.context) - return contextArray.includes(match.context); - return true; - }) - .filter(({match}) => { - if (match.pathname) return comparePathname(match.pathname); - if (match.pathnames) return match.pathnames.some(comparePathname); - return true; - }) - .filter(({match}) => { - if (match.query) return compareQuery(match.query); - if (match.queries) return match.quieries.some(compareQuery); - return true; - }); + .filter(({match}) => + (match.domain + ? compareDomain(match.domain) + : match.domains + ? match.domains.some(compareDomain) + : false)) + + .filter(({match}) => + (Array.isArray(match.context) + ? match.context.some(c => contextArray.includes(c)) + : match.context + ? contextArray.includes(match.context) + : true)) + + .filter(({match}) => + (match.pathname + ? comparePathname(match.pathname) + : match.pathnames + ? match.pathnames.some(comparePathname) + : true)) + + .filter(({match}) => + (match.query + ? compareQuery(match.query) + : match.queries + ? match.quieries.some(compareQuery) + : true)); return [...matchingDescriptors, fallbackDescriptor]; } -- cgit 1.3.0-6-gf8a5