@availity/env-var
Advanced tools
Comparing version 1.11.1-alpha.33 to 1.11.1
@@ -6,2 +6,10 @@ # Change Log | ||
## 1.11.1 (2021-05-17) | ||
**Note:** Version bump only for package @availity/env-var | ||
# 1.11.0 (2020-06-03) | ||
@@ -8,0 +16,0 @@ |
@@ -35,5 +35,5 @@ "use strict"; | ||
if (!(subdomain && pathname)) return null; | ||
var subMatch = subdomain.match(/.*?\.(?:aw|az|gc)(n|p|s)$/); | ||
var subMatch = subdomain.match(/.*?\.(?:aw|az|gc)([nps])$/); | ||
if (!subMatch) return null; | ||
var pathMatch = pathname.match(/^\/[a-z]{3}\/([a-z0-9]{3})\/.*/); | ||
var pathMatch = pathname.match(/^\/[a-z]{3}\/([\da-z]{3})\/.*/); | ||
if (!pathMatch) return null; // ??p domains must be prod, ??n and ??s domains can't be prod | ||
@@ -74,3 +74,3 @@ | ||
}, { | ||
regex: /.*?\.(?:aw|az|gc)(n|p|s)$/, | ||
regex: /.*?\.(?:aw|az|gc)([nps])$/, | ||
fn: getCloudEnv | ||
@@ -128,13 +128,12 @@ }]; | ||
return envTests.some(function (test) { | ||
switch (Object.prototype.toString.call(test)) { | ||
return envTests.some(function (testObj) { | ||
switch (Object.prototype.toString.call(testObj)) { | ||
case '[object String]': | ||
return test === subdomain; | ||
return testObj === subdomain; | ||
case '[object RegExp]': | ||
return test.test(subdomain); | ||
return testObj.test(subdomain); | ||
case '[object Function]': | ||
// eslint-disable-next-line jest/no-disabled-tests | ||
return test({ | ||
return testObj({ | ||
subdomain: subdomain, | ||
@@ -170,4 +169,5 @@ pathname: pathname | ||
}, null) || 'local'; | ||
} | ||
} // eslint-disable-next-line func-names | ||
function _default(varObj, windowOverride, defaultVar) { | ||
@@ -174,0 +174,0 @@ var env = getCurrentEnv(windowOverride); |
{ | ||
"name": "@availity/env-var", | ||
"version": "1.11.1-alpha.33+a2b3164", | ||
"version": "1.11.1", | ||
"description": "Availity-specific way to determine variables based on the current environment the code is running in", | ||
@@ -31,3 +31,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "a2b31645b933229b33935f4ff16aa299ec4a25af" | ||
"gitHead": "4e1d7493ccf0ba9e776476efc86088f4324618cd" | ||
} |
@@ -7,10 +7,10 @@ // Cloud domains are in the format <team>.<cloud provider><zone>.availity.com | ||
// and <environment> is a three character abbreviation, e.g., prd or t01 | ||
const getCloudEnv = options => { | ||
const getCloudEnv = (options) => { | ||
const { subdomain, pathname } = options; | ||
if (!(subdomain && pathname)) return null; | ||
const subMatch = subdomain.match(/.*?\.(?:aw|az|gc)(n|p|s)$/); | ||
const subMatch = subdomain.match(/.*?\.(?:aw|az|gc)([nps])$/); | ||
if (!subMatch) return null; | ||
const pathMatch = pathname.match(/^\/[a-z]{3}\/([a-z0-9]{3})\/.*/); | ||
const pathMatch = pathname.match(/^\/[a-z]{3}\/([\da-z]{3})\/.*/); | ||
if (!pathMatch) return null; | ||
@@ -35,9 +35,10 @@ | ||
/^t(?:(?:\d\d)|(?:est))-apps$/, | ||
options => /^t(?:(?:\d\d)|(?:st))$/.test(getCloudEnv(options)), | ||
(options) => /^t(?:(?:\d\d)|(?:st))$/.test(getCloudEnv(options)), | ||
], | ||
qa: [ | ||
/^q(?:(?:\d\d)|(?:ap?))-apps$/, | ||
options => /^(stg|q(?:(?:\d\d)|(?:ua)|(?:ap)))$/.test(getCloudEnv(options)), | ||
(options) => | ||
/^(stg|q(?:(?:\d\d)|(?:ua)|(?:ap)))$/.test(getCloudEnv(options)), | ||
], | ||
prod: [/^apps$/, options => getCloudEnv(options) === 'prd'], | ||
prod: [/^apps$/, (options) => getCloudEnv(options) === 'prd'], | ||
}; | ||
@@ -48,6 +49,6 @@ | ||
regex: /^(?:(.*)-)?apps$/, | ||
fn: options => options.match[1] || 'prod', | ||
fn: (options) => options.match[1] || 'prod', | ||
}, | ||
{ | ||
regex: /.*?\.(?:aw|az|gc)(n|p|s)$/, | ||
regex: /.*?\.(?:aw|az|gc)([nps])$/, | ||
fn: getCloudEnv, | ||
@@ -102,11 +103,10 @@ }, | ||
return ( | ||
envTests.some(test => { | ||
switch (Object.prototype.toString.call(test)) { | ||
envTests.some((testObj) => { | ||
switch (Object.prototype.toString.call(testObj)) { | ||
case '[object String]': | ||
return test === subdomain; | ||
return testObj === subdomain; | ||
case '[object RegExp]': | ||
return test.test(subdomain); | ||
return testObj.test(subdomain); | ||
case '[object Function]': | ||
// eslint-disable-next-line jest/no-disabled-tests | ||
return test({ subdomain, pathname }); | ||
return testObj({ subdomain, pathname }); | ||
default: | ||
@@ -134,3 +134,4 @@ return false; | ||
export default function(varObj, windowOverride, defaultVar) { | ||
// eslint-disable-next-line func-names | ||
export default function (varObj, windowOverride, defaultVar) { | ||
const env = getCurrentEnv(windowOverride); | ||
@@ -137,0 +138,0 @@ |
@@ -30,3 +30,3 @@ import envVar, { setEnvironments, getSpecificEnv } from '../src'; | ||
describe('Default environments', () => { | ||
[ | ||
for (const args of [ | ||
['fallback-apps.availity.com', 'local'], | ||
@@ -73,8 +73,8 @@ ['localhost', 'local'], | ||
['digital.gcn.availity.com/cdn/t25/spaces/index.html', 'test'], | ||
].forEach(args => { | ||
]) { | ||
generateTest(...args); | ||
}); | ||
} | ||
describe('Override window', () => { | ||
[ | ||
for (const args of [ | ||
[ | ||
@@ -147,9 +147,9 @@ 'fallback-apps.availity.com', | ||
], | ||
].forEach(args => { | ||
]) { | ||
generateTest(...args); | ||
}); | ||
} | ||
}); | ||
describe('Provide URL', () => { | ||
[ | ||
for (const args of [ | ||
['fallback-apps.availity.com', 'prod', 'https://apps.availity.com'], | ||
@@ -205,5 +205,5 @@ ['localhost', 'prod', 'https://apps.availity.com'], | ||
], | ||
].forEach(args => { | ||
]) { | ||
generateTest(...args); | ||
}); | ||
} | ||
}); | ||
@@ -347,3 +347,3 @@ }); | ||
describe('Specific environments', () => { | ||
[ | ||
for (const args of [ | ||
['fallback-apps.availity.com', 'fallback'], | ||
@@ -395,6 +395,6 @@ ['localhost', 'local'], | ||
['digital.aws.availity.com/nahfam/stg/spaces/index.html', 'local'], | ||
].forEach(args => { | ||
]) { | ||
generateSpecificTest(...args); | ||
}); | ||
} | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
31482
0
1