MCPcopy Index your code
hub / github.com/libredirect/browser_extension / regexArray

Function regexArray

src/assets/javascripts/services.js:37–57  ·  view source on GitHub ↗

* @param {string} service * @param {URL} url * @param {{}} config * @param {{}} options * @param {string} frontend

(service, url, config, options, frontend)

Source from the content-addressed store, hash-verified

35 * @param {string} frontend
36 */
37function regexArray(service, url, config, options, frontend) {
38 let targetList = config.services[service].targets
39 if (frontend) {
40 if (
41 "excludeTargets" in config.services[service].frontends[frontend] &&
42 (service !== "search" || !options["search"].redirectGoogle)
43 ) {
44 targetList = targetList.filter(
45 val => !config.services[service].frontends[frontend].excludeTargets.includes(targetList.indexOf(val))
46 )
47 }
48 if (service === "twitter" && options["twitter"].disableTwimg) {
49 targetList.splice(2, 1)
50 }
51 }
52 for (const targetString in targetList) {
53 const target = new RegExp(targetList[targetString])
54 if (target.test(url.href)) return true
55 }
56 return false
57}
58
59/**
60 * @param {URL} url

Callers 2

redirectFunction · 0.85
computeServiceFrontendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected