Taichi Masuyama 4 лет назад
Родитель
Сommit
68450c9dc1

+ 4 - 4
packages/app/src/server/service/page.ts

@@ -26,7 +26,7 @@ const debug = require('debug')('growi:services:page');
 
 const logger = loggerFactory('growi:services:page');
 const {
-  isCreatablePage, isTrashPage, isTopPage, omitDuplicatePathAreaFromPaths,
+  isCreatablePage, isTrashPage, isTopPage, omitDuplicateAreaPathFromPaths,
 } = pagePathUtils;
 
 const BULK_REINDEX_SIZE = 100;
@@ -1943,7 +1943,7 @@ class PageService {
   /*
    * returns an array of js RegExp instance instead of RE2 instance for mongo filter
    */
-  private async _generateRegExpsByPageIds(pageIds, shouldOmitDuplicatePathArea: boolean) {
+  private async _generateRegExpsByPageIds(pageIds, shouldOmitDuplicateAreaPath: boolean) {
     const Page = mongoose.model('Page') as unknown as PageModel;
 
     let result;
@@ -1958,8 +1958,8 @@ class PageService {
     const { pages } = result;
 
     let paths = pages.map(p => p.path);
-    if (shouldOmitDuplicatePathArea) {
-      paths = omitDuplicatePathAreaFromPaths(paths);
+    if (shouldOmitDuplicateAreaPath) {
+      paths = omitDuplicateAreaPathFromPaths(paths);
     }
 
     const regexps = paths.map(path => new RegExp(`^${escapeStringRegexp(path)}`));

+ 6 - 6
packages/core/src/test/util/page-path-utils.test.js

@@ -1,5 +1,5 @@
 import {
-  isTopPage, convertToNewAffiliationPath, isCreatablePage, omitDuplicatePathAreaFromPaths,
+  isTopPage, convertToNewAffiliationPath, isCreatablePage, omitDuplicateAreaPathFromPaths,
 } from '~/utils/page-path-utils';
 
 describe('TopPage Path test', () => {
@@ -106,33 +106,33 @@ describe('isCreatablePage test', () => {
     }
   });
 
-  describe('Test omitDuplicatePathAreaFromPaths', () => {
+  describe('Test omitDuplicateAreaPathFromPaths', () => {
     test('Should not omit when all paths are at unique area', () => {
       const paths = ['/A', '/B/A', '/C/B/A', '/D'];
       const expectedPaths = paths;
 
-      expect(omitDuplicatePathAreaFromPaths(paths)).toStrictEqual(paths);
+      expect(omitDuplicateAreaPathFromPaths(paths)).toStrictEqual(paths);
     });
 
     test('Should omit when some paths are at duplicated area', () => {
       const paths = ['/A', '/A/A', '/A/B/A', '/B', '/B/A', '/AA'];
       const expectedPaths = ['/A', '/B', '/AA'];
 
-      expect(omitDuplicatePathAreaFromPaths(paths)).toStrictEqual(expectedPaths);
+      expect(omitDuplicateAreaPathFromPaths(paths)).toStrictEqual(expectedPaths);
     });
 
     test('Should omit when some long paths are at duplicated area', () => {
       const paths = ['/A/B/C', '/A/B/C/D', '/A/B/C/D/E'];
       const expectedPaths = ['/A/B/C'];
 
-      expect(omitDuplicatePathAreaFromPaths(paths)).toStrictEqual(expectedPaths);
+      expect(omitDuplicateAreaPathFromPaths(paths)).toStrictEqual(expectedPaths);
     });
 
     test('Should omit when some long paths are at duplicated area [case insensitivity]', () => {
       const paths = ['/a/B/C', '/A/b/C/D', '/A/B/c/D/E'];
       const expectedPaths = ['/a/B/C'];
 
-      expect(omitDuplicatePathAreaFromPaths(paths)).toStrictEqual(expectedPaths);
+      expect(omitDuplicateAreaPathFromPaths(paths)).toStrictEqual(expectedPaths);
     });
   });
 });

+ 2 - 2
packages/core/src/utils/page-path-utils.ts

@@ -164,11 +164,11 @@ export const collectAncestorPaths = (path: string, ancestorPaths: string[] = [])
 
 /**
  * return paths without duplicate area of regexp /^${path}\/.+/i
- * ex. expect(omitDuplicatePathAreaFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])
+ * ex. expect(omitDuplicateAreaPathFromPaths(['/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 omitDuplicateAreaPathFromPaths = (paths: string[]): string[] => {
   return paths.filter((path) => {
     const isDuplicate = paths.filter(p => (new RegExp(`^${p}\\/.+`, 'i')).test(path)).length > 0;