|
|
@@ -943,7 +943,13 @@ module.exports = function(crowi) {
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
- * remove the page that is redirecting to specified `pagePath`
|
|
|
+ * remove the page that is redirecting to specified `pagePath` recursively
|
|
|
+ * ex: when
|
|
|
+ * '/page1' redirects to '/page2' and
|
|
|
+ * '/page2' redirects to '/page3'
|
|
|
+ * and given '/page3',
|
|
|
+ * '/page1' and '/page2' will be removed
|
|
|
+ *
|
|
|
* @param {string} pagePath
|
|
|
*/
|
|
|
pageSchema.statics.removeRedirectOriginPageByPath = function(pagePath) {
|
|
|
@@ -951,7 +957,12 @@ module.exports = function(crowi) {
|
|
|
|
|
|
return Page.findPageByRedirectTo(pagePath)
|
|
|
.then((redirectOriginPageData) => {
|
|
|
- return Page.removePageById(redirectOriginPageData.id);
|
|
|
+ // remove
|
|
|
+ return Page.removePageById(redirectOriginPageData.id)
|
|
|
+ // remove recursive
|
|
|
+ .then(() => {
|
|
|
+ return Page.removeRedirectOriginPageByPath(redirectOriginPageData.path)
|
|
|
+ });
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
// do nothing if origin page doesn't exist
|