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

use pathUtils.addTrailingSlash

mizozobu 6 лет назад
Родитель
Сommit
e7a21557fc
1 измененных файлов с 3 добавлено и 5 удалено
  1. 3 5
      src/server/models/GlobalNotificationSetting/index.js

+ 3 - 5
src/server/models/GlobalNotificationSetting/index.js

@@ -1,5 +1,6 @@
 const mongoose = require('mongoose');
 const nodePath = require('path');
+const { pathUtils } = require('growi-commons');
 
 /**
  * parent schema for GlobalNotificationSetting model
@@ -32,12 +33,9 @@ const generatePathsToMatch = (originalPath) => {
   const pathList = generatePathsOnTree(originalPath, []);
   return pathList.map((path) => {
     // except for the original trigger path ("/a/b/c"), append "*" to find all matches
-    // ["/a/b/c", "/a/b", "/a", "/"] => ["/a/b/c", "/a/b/*", "/a/*", "/*"]
+    // e.g. ["/a/b/c", "/a/b", "/a", "/"] => ["/a/b/c", "/a/b/*", "/a/*", "/*"]
     if (path !== originalPath) {
-      if (path.substr(-1) === '/') {
-        return `${path}*`;
-      }
-      return `${path}/*`;
+      return `${pathUtils.addTrailingSlash(path)}*`;
     }
 
     return path;