Browse Source

remove option

itizawa 5 years ago
parent
commit
b89d6bd9a4
1 changed files with 6 additions and 14 deletions
  1. 6 14
      src/server/models/page.js

+ 6 - 14
src/server/models/page.js

@@ -150,15 +150,12 @@ class PageQueryBuilder {
   /**
   /**
    * generate the query to find the page that is match with `path` and its descendants
    * generate the query to find the page that is match with `path` and its descendants
    */
    */
-  addConditionToListWithDescendants(path, option) {
+  addConditionToListWithDescendants(path) {
     // ignore other pages than descendants
     // ignore other pages than descendants
     // eslint-disable-next-line no-param-reassign
     // eslint-disable-next-line no-param-reassign
     path = addSlashOfEnd(path);
     path = addSlashOfEnd(path);
 
 
-    // add option to escape the regex strings
-    const combinedOption = Object.assign({ isRegExpEscapedFromPath: true }, option);
-
-    this.addConditionToListByStartWith(path, combinedOption);
+    this.addConditionToListByStartWith(path);
     return this;
     return this;
   }
   }
 
 
@@ -168,16 +165,13 @@ class PageQueryBuilder {
    * In normal case, returns '{path}/*' and '{path}' self.
    * In normal case, returns '{path}/*' and '{path}' self.
    * If top page, return without doing anything.
    * If top page, return without doing anything.
    *
    *
-   * *option*
-   *   - isRegExpEscapedFromPath -- if true, the regex strings included in `path` is escaped (default: false)
    */
    */
-  addConditionToListByStartWith(path, option) {
+  addConditionToListByStartWith(path) {
     // No request is set for the top page
     // No request is set for the top page
     if (isTopPage(path)) {
     if (isTopPage(path)) {
       return this;
       return this;
     }
     }
     const pathCondition = [];
     const pathCondition = [];
-    const isRegExpEscapedFromPath = option.isRegExpEscapedFromPath || false;
 
 
     /*
     /*
      * 1. add condition for finding the page completely match with `path` w/o last slash
      * 1. add condition for finding the page completely match with `path` w/o last slash
@@ -190,9 +184,7 @@ class PageQueryBuilder {
     /*
     /*
      * 2. add decendants
      * 2. add decendants
      */
      */
-    const pattern = (isRegExpEscapedFromPath)
-      ? escapeStringRegexp(path) // escape
-      : pathSlashOmitted;
+    const pattern = escapeStringRegexp(path); // escape
 
 
     let queryReg;
     let queryReg;
     try {
     try {
@@ -698,7 +690,7 @@ module.exports = function(crowi) {
    */
    */
   pageSchema.statics.findListWithDescendants = async function(path, user, option) {
   pageSchema.statics.findListWithDescendants = async function(path, user, option) {
     const builder = new PageQueryBuilder(this.find());
     const builder = new PageQueryBuilder(this.find());
-    builder.addConditionToListWithDescendants(path, option);
+    builder.addConditionToListWithDescendants(path);
 
 
     return await findListFromBuilderAndViewer(builder, user, false, option);
     return await findListFromBuilderAndViewer(builder, user, false, option);
   };
   };
@@ -708,7 +700,7 @@ module.exports = function(crowi) {
    */
    */
   pageSchema.statics.findListByStartWith = async function(path, user, option) {
   pageSchema.statics.findListByStartWith = async function(path, user, option) {
     const builder = new PageQueryBuilder(this.find());
     const builder = new PageQueryBuilder(this.find());
-    builder.addConditionToListByStartWith(path, option);
+    builder.addConditionToListByStartWith(path);
 
 
     return await findListFromBuilderAndViewer(builder, user, false, option);
     return await findListFromBuilderAndViewer(builder, user, false, option);
   };
   };