Move private function definitions inside of IIFE (#641)

This commit is contained in:
toasted-nutbread 2020-07-03 12:00:13 -04:00 committed by GitHub
parent 562cfd7470
commit 6ede83f293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,10 @@
* Environment * Environment
*/ */
function _profileConditionTestDomain(urlDomain, domain) { let profileConditionsDescriptor = null;
const profileConditionsDescriptorPromise = (async () => {
function profileConditionTestDomain(urlDomain, domain) {
return ( return (
urlDomain.endsWith(domain) && urlDomain.endsWith(domain) &&
( (
@ -27,21 +30,18 @@ function _profileConditionTestDomain(urlDomain, domain) {
urlDomain[urlDomain.length - domain.length - 1] === '.' urlDomain[urlDomain.length - domain.length - 1] === '.'
) )
); );
} }
function _profileConditionTestDomainList(url, domainList) { function profileConditionTestDomainList(url, domainList) {
const urlDomain = new URL(url).hostname.toLowerCase(); const urlDomain = new URL(url).hostname.toLowerCase();
for (const domain of domainList) { for (const domain of domainList) {
if (_profileConditionTestDomain(urlDomain, domain)) { if (profileConditionTestDomain(urlDomain, domain)) {
return true; return true;
} }
} }
return false; return false;
} }
let profileConditionsDescriptor = null;
const profileConditionsDescriptorPromise = (async () => {
const environment = new Environment(); const environment = new Environment();
await environment.prepare(); await environment.prepare();
@ -111,7 +111,7 @@ const profileConditionsDescriptorPromise = (async () => {
transform: (optionValue) => optionValue.split(/[,;\s]+/).map((v) => v.trim().toLowerCase()).filter((v) => v.length > 0), transform: (optionValue) => optionValue.split(/[,;\s]+/).map((v) => v.trim().toLowerCase()).filter((v) => v.length > 0),
transformReverse: (transformedOptionValue) => transformedOptionValue.join(', '), transformReverse: (transformedOptionValue) => transformedOptionValue.join(', '),
validateTransformed: (transformedOptionValue) => (transformedOptionValue.length > 0), validateTransformed: (transformedOptionValue) => (transformedOptionValue.length > 0),
test: ({url}, transformedOptionValue) => _profileConditionTestDomainList(url, transformedOptionValue) test: ({url}, transformedOptionValue) => profileConditionTestDomainList(url, transformedOptionValue)
}, },
matchRegExp: { matchRegExp: {
name: 'Matches RegExp', name: 'Matches RegExp',