diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-29 19:29:50 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-03-29 20:41:54 -0300 |
commit | eac58883fd56d2e2d3dd2cbb5b8b01259b1896df (patch) | |
tree | 6975be07fee51978cb07334ff0aea455ca345f64 | |
parent | 40d6c1c3bd8c454479cdb283086b4bfc339688fe (diff) |
external-links: matchingDescriptors syntax cleanup
-rw-r--r-- | src/util/external-links.js | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/util/external-links.js b/src/util/external-links.js index c5f51393..6d993ee0 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]; } |