You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/ui-v2/app/utils/keyToArray.js

13 lines
427 B

/**
* Turns a separated path or 'key name' in this case to
* an array. If the key name is simply the separator (for example '/')
* then the array should contain a single empty string value
*
* @param {string} key - The separated path/key
* @param {string} [separator=/] - The separator
* @returns {string[]}
*/
export default function(key, separator = '/') {
return (key === separator ? '' : key).split(separator);
}