|
@@ -162,6 +162,12 @@ export const collectAncestorPaths = (path: string, ancestorPaths: string[] = [])
|
|
|
return collectAncestorPaths(parentPath, ancestorPaths);
|
|
return collectAncestorPaths(parentPath, ancestorPaths);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * return paths without duplicate area of regexp /^${path}\/.+/i
|
|
|
|
|
+ * ex. expect(omitDuplicatePathAreaFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])
|
|
|
|
|
+ * @param paths paths to be tested
|
|
|
|
|
+ * @returns omitted paths
|
|
|
|
|
+ */
|
|
|
export const omitDuplicatePathAreaFromPaths = (paths: string[]): string[] => {
|
|
export const omitDuplicatePathAreaFromPaths = (paths: string[]): string[] => {
|
|
|
return paths.filter((path) => {
|
|
return paths.filter((path) => {
|
|
|
const isDuplicate = paths.filter(p => (new RegExp(`^${p}\\/.+`, 'i')).test(path)).length > 0;
|
|
const isDuplicate = paths.filter(p => (new RegExp(`^${p}\\/.+`, 'i')).test(path)).length > 0;
|