da4cb6422e
* Recursive trie-building with variable paths * tree structure applied to new path routes and a new util class * Breadcrumbs for SV paths and prompt when nothing exists at a path * Lint and test cleanup * Pre-review cleanup * lintfix * Abstracted pathtree each-ins into a new component class * Path tree component styles * Types added and PR feedback addressed * Path tree to variable paths * Slightly simpler path QP mods * More pr feedback handling * Trim moved into a function on variable model * Traversal and compaction tests for PathTree * Trim Path tests * Variable-paths component tests * Lint fixup for tests
20 lines
437 B
JavaScript
20 lines
437 B
JavaScript
// @ts-check
|
|
import Helper from '@ember/component/helper';
|
|
|
|
/**
|
|
* Trims any number of slashes from the beginning and end of a string.
|
|
* @param {Array<string>} params
|
|
* @returns {string}
|
|
*/
|
|
export function trimPath([path = '']) {
|
|
if (path.startsWith('/')) {
|
|
path = trimPath([path.slice(1)]);
|
|
}
|
|
if (path.endsWith('/')) {
|
|
path = trimPath([path.slice(0, -1)]);
|
|
}
|
|
return path;
|
|
}
|
|
|
|
export default Helper.helper(trimPath);
|