mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-28 22:21:30 +01:00
[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:
parent
436c9635f6
commit
482ad0a094
@ -10,7 +10,8 @@ export function extractDataAndFlags(data, flags) {
|
|||||||
(accumulator, val) => {
|
(accumulator, val) => {
|
||||||
// will be "key=value" or "-flag=value" or "foo=bar=baz"
|
// will be "key=value" or "-flag=value" or "foo=bar=baz"
|
||||||
// split on the first =
|
// split on the first =
|
||||||
let [item, value] = val.split(/=(.+)/);
|
// default to value of empty string
|
||||||
|
let [item, value = ''] = val.split(/=(.+)?/);
|
||||||
if (item.startsWith('-')) {
|
if (item.startsWith('-')) {
|
||||||
let flagName = item.replace(/^-/, '');
|
let flagName = item.replace(/^-/, '');
|
||||||
if (flagName === 'wrap-ttl') {
|
if (flagName === 'wrap-ttl') {
|
||||||
@ -26,7 +27,6 @@ export function extractDataAndFlags(data, flags) {
|
|||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
accumulator.data[item] = value;
|
accumulator.data[item] = value;
|
||||||
|
|
||||||
return accumulator;
|
return accumulator;
|
||||||
},
|
},
|
||||||
{ data: {}, flags: {} }
|
{ data: {}, flags: {} }
|
||||||
|
|||||||
@ -166,6 +166,17 @@ module('Unit | Lib | console helpers', function() {
|
|||||||
flags: {},
|
flags: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'data with empty values',
|
||||||
|
input: [[`foo=`, 'some=thing'], []],
|
||||||
|
expected: {
|
||||||
|
data: {
|
||||||
|
foo: '',
|
||||||
|
some: 'thing',
|
||||||
|
},
|
||||||
|
flags: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
testExtractCases.forEach(function(testCase) {
|
testExtractCases.forEach(function(testCase) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user