Taichi Masuyama 4 лет назад
Родитель
Сommit
1d825692ec
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      packages/core/src/utils/page-path-utils.ts

+ 6 - 0
packages/core/src/utils/page-path-utils.ts

@@ -162,6 +162,12 @@ export const collectAncestorPaths = (path: string, ancestorPaths: string[] = [])
   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[] => {
   return paths.filter((path) => {
     const isDuplicate = paths.filter(p => (new RegExp(`^${p}\\/.+`, 'i')).test(path)).length > 0;