Răsfoiți Sursa

Added trailing slash

Taichi Masuyama 4 ani în urmă
părinte
comite
f9bd8a2195
1 a modificat fișierele cu 4 adăugiri și 2 ștergeri
  1. 4 2
      packages/app/src/server/service/page.ts

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

@@ -1,4 +1,4 @@
-import { pagePathUtils } from '@growi/core';
+import { pagePathUtils, pathUtils } from '@growi/core';
 import mongoose, { ObjectId, QueryCursor } from 'mongoose';
 import escapeStringRegexp from 'escape-string-regexp';
 import streamToPromise from 'stream-to-promise';
@@ -32,6 +32,8 @@ const {
   collectAncestorPaths, isMovablePage,
 } = pagePathUtils;
 
+const { addTrailingSlash } = pathUtils;
+
 const BULK_REINDEX_SIZE = 100;
 const LIMIT_FOR_MULTIPLE_PAGE_OP = 20;
 
@@ -2365,7 +2367,7 @@ class PageService {
 
   async normalizeParentRecursively(paths: string[], publicOnly = false): Promise<void> {
     const ancestorPaths = paths.flatMap(p => collectAncestorPaths(p));
-    const regexps = paths.map(p => new RegExp(`^${escapeStringRegexp(p)}`, 'i'));
+    const regexps = paths.map(p => new RegExp(`^${escapeStringRegexp(addTrailingSlash(p))}`, 'i'));
 
     return this._normalizeParentRecursively(regexps, ancestorPaths, publicOnly);
   }