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,29 +19,29 @@
* Environment * Environment
*/ */
function _profileConditionTestDomain(urlDomain, domain) {
return (
urlDomain.endsWith(domain) &&
(
domain.length === urlDomain.length ||
urlDomain[urlDomain.length - domain.length - 1] === '.'
)
);
}
function _profileConditionTestDomainList(url, domainList) {
const urlDomain = new URL(url).hostname.toLowerCase();
for (const domain of domainList) {
if (_profileConditionTestDomain(urlDomain, domain)) {
return true;
}
}
return false;
}
let profileConditionsDescriptor = null; let profileConditionsDescriptor = null;
const profileConditionsDescriptorPromise = (async () => { const profileConditionsDescriptorPromise = (async () => {
function profileConditionTestDomain(urlDomain, domain) {
return (
urlDomain.endsWith(domain) &&
(
domain.length === urlDomain.length ||
urlDomain[urlDomain.length - domain.length - 1] === '.'
)
);
}
function profileConditionTestDomainList(url, domainList) {
const urlDomain = new URL(url).hostname.toLowerCase();
for (const domain of domainList) {
if (profileConditionTestDomain(urlDomain, domain)) {
return true;
}
}
return false;
}
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',