Просмотр исходного кода

refactor(suggest-path): use pathUtils.removeTrailingSlash instead of manual regex

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
VANELLOPE\tomoyuki-t 1 месяц назад
Родитель
Сommit
5e4abd70d7

+ 2 - 1
apps/app/src/features/suggest-path/server/services/resolve-parent-grant.ts

@@ -1,4 +1,5 @@
 import { PageGrant } from '@growi/core';
+import { pathUtils } from '@growi/core/dist/utils';
 import mongoose, { type Model } from 'mongoose';
 
 type PageWithGrant = { grant: number };
@@ -30,7 +31,7 @@ const findGrantInAncestors = async (
 
 export const resolveParentGrant = async (dirPath: string): Promise<number> => {
   const Page = mongoose.model('Page');
-  const pagePath = dirPath.replace(/\/$/, '') || '/';
+  const pagePath = pathUtils.removeTrailingSlash(dirPath);
 
   const grant = await findGrantInAncestors(Page, pagePath);
   return grant ?? PageGrant.GRANT_OWNER;