[UI] clear policies in cli (#8291)

* fix: entity policies cleared from empty string in UI console

* add test for new use case of empty value
This commit is contained in:
Chelsea Shaw 2020-02-06 12:37:38 -06:00 committed by GitHub
parent d2cc5dee0c
commit 937b0550ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -10,7 +10,8 @@ export function extractDataAndFlags(data, flags) {
(accumulator, val) => {
// will be "key=value" or "-flag=value" or "foo=bar=baz"
// split on the first =
let [item, value] = val.split(/=(.+)/);
// default to value of empty string
let [item, value = ''] = val.split(/=(.+)?/);
if (item.startsWith('-')) {
let flagName = item.replace(/^-/, '');
if (flagName === 'wrap-ttl') {
@ -26,7 +27,6 @@ export function extractDataAndFlags(data, flags) {
return accumulator;
}
accumulator.data[item] = value;
return accumulator;
},
{ data: {}, flags: {} }

View File

@ -166,6 +166,17 @@ module('Unit | Lib | console helpers', function() {
flags: {},
},
},
{
name: 'data with empty values',
input: [[`foo=`, 'some=thing'], []],
expected: {
data: {
foo: '',
some: 'thing',
},
flags: {},
},
},
];
testExtractCases.forEach(function(testCase) {