(script, url = location?.href)
| 10 | }; |
| 11 | |
| 12 | export function checkBlackWhiteList(script, url = location?.href) { |
| 13 | if (!url) return false; |
| 14 | let hasWhiteList = script.whiteList?.length > 0; |
| 15 | let hasBlackList = script.blackList?.length > 0; |
| 16 | let inWhiteList = matchOneOfPatterns(url, script.whiteList || []); |
| 17 | let inBlackList = matchOneOfPatterns(url, script.blackList || []); |
| 18 | return ( |
| 19 | (!hasWhiteList && !hasBlackList) || |
| 20 | (hasWhiteList && inWhiteList) || |
| 21 | (hasBlackList && !inBlackList) |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | export function matchOneOfPatterns(url, patterns) { |
| 26 | for (let pattern of patterns) { |
no test coverage detected