Taichi Masuyama пре 4 година
родитељ
комит
0c4696af75

+ 2 - 2
packages/app/src/server/models/page-redirect.ts

@@ -26,8 +26,8 @@ const schema = new Schema<PageRedirectDocument, PageRedirectModel>({
   toPath: { type: String, required: true },
   toPath: { type: String, required: true },
 });
 });
 
 
-schema.statics.removePageRedirectByFromPath = async function(fromPath: string): Promise<void> {
-  await this.deleteOne({ fromPath });
+schema.statics.removePageRedirectByToPath = async function(toPath: string): Promise<void> {
+  await this.deleteMany({ toPath });
 
 
   return;
   return;
 };
 };

+ 4 - 4
packages/app/src/server/routes/page.js

@@ -1349,18 +1349,18 @@ module.exports = function(crowi, app) {
    * @apiParam {String} revision_id
    * @apiParam {String} revision_id
    */
    */
   api.unlink = async function(req, res) {
   api.unlink = async function(req, res) {
-    const fromPath = req.body.path;
+    const path = req.body.path;
 
 
     try {
     try {
-      await PageRedirect.removePageRedirectByFromPath(fromPath);
-      logger.debug('Redirect Page deleted', fromPath);
+      await PageRedirect.removePageRedirectByToPath(path);
+      logger.debug('Redirect Page deleted', path);
     }
     }
     catch (err) {
     catch (err) {
       logger.error('Error occured while get setting', err);
       logger.error('Error occured while get setting', err);
       return res.json(ApiResponse.error('Failed to delete redirect page.'));
       return res.json(ApiResponse.error('Failed to delete redirect page.'));
     }
     }
 
 
-    const result = { path: fromPath };
+    const result = { path };
     return res.json(ApiResponse.success(result));
     return res.json(ApiResponse.success(result));
   };
   };