From 49f76d27a9967cbeff0ba5b3d41277c558999472 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 6 Oct 2017 00:04:01 -0230 Subject: Adds checkFeatureToggle util. --- ui/lib/feature-toggle-utils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 ui/lib/feature-toggle-utils.js (limited to 'ui/lib') diff --git a/ui/lib/feature-toggle-utils.js b/ui/lib/feature-toggle-utils.js new file mode 100644 index 000000000..f4ff446d3 --- /dev/null +++ b/ui/lib/feature-toggle-utils.js @@ -0,0 +1,11 @@ +function checkFeatureToggle(name) { + const queryPairMap = window.location.search.substr(1).split('&') + .map(pair => pair.split('=')) + .reduce((pairs, [key, value]) => ({...pairs, [key]: value }), {}) + const featureToggles = queryPairMap['ft'] ? queryPairMap['ft'].split(',') : [] + return Boolean(featureToggles.find(ft => ft === name)) +} + +module.exports = { + checkFeatureToggle, +} \ No newline at end of file -- cgit