|
@@ -1070,7 +1070,7 @@ module.exports = function(crowi, app) {
|
|
|
api.rename = async function(req, res) {
|
|
api.rename = async function(req, res) {
|
|
|
const pageId = req.body.page_id;
|
|
const pageId = req.body.page_id;
|
|
|
const previousRevision = req.body.revision_id || null;
|
|
const previousRevision = req.body.revision_id || null;
|
|
|
- const newPagePath = pathUtils.normalizePath(req.body.new_path);
|
|
|
|
|
|
|
+ let newPagePath = pathUtils.normalizePath(req.body.new_path);
|
|
|
const options = {
|
|
const options = {
|
|
|
createRedirectPage: (req.body.create_redirect != null),
|
|
createRedirectPage: (req.body.create_redirect != null),
|
|
|
updateMetadata: (req.body.remain_metadata == null),
|
|
updateMetadata: (req.body.remain_metadata == null),
|
|
@@ -1082,6 +1082,9 @@ module.exports = function(crowi, app) {
|
|
|
return res.json(ApiResponse.error(`Could not use the path '${newPagePath})'`, 'invalid_path'));
|
|
return res.json(ApiResponse.error(`Could not use the path '${newPagePath})'`, 'invalid_path'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // check whether path starts slash
|
|
|
|
|
+ newPagePath = pathUtils.addHeadingSlash(newPagePath);
|
|
|
|
|
+
|
|
|
const isExist = await Page.count({ path: newPagePath }) > 0;
|
|
const isExist = await Page.count({ path: newPagePath }) > 0;
|
|
|
if (isExist) {
|
|
if (isExist) {
|
|
|
// if page found, cannot cannot rename to that path
|
|
// if page found, cannot cannot rename to that path
|
|
@@ -1136,7 +1139,7 @@ module.exports = function(crowi, app) {
|
|
|
*/
|
|
*/
|
|
|
api.duplicate = async function(req, res) {
|
|
api.duplicate = async function(req, res) {
|
|
|
const pageId = req.body.page_id;
|
|
const pageId = req.body.page_id;
|
|
|
- const newPagePath = pathUtils.normalizePath(req.body.new_path);
|
|
|
|
|
|
|
+ let newPagePath = pathUtils.normalizePath(req.body.new_path);
|
|
|
|
|
|
|
|
const page = await Page.findByIdAndViewer(pageId, req.user);
|
|
const page = await Page.findByIdAndViewer(pageId, req.user);
|
|
|
|
|
|
|
@@ -1144,6 +1147,9 @@ module.exports = function(crowi, app) {
|
|
|
return res.json(ApiResponse.error(`Page '${pageId}' is not found or forbidden`, 'notfound_or_forbidden'));
|
|
return res.json(ApiResponse.error(`Page '${pageId}' is not found or forbidden`, 'notfound_or_forbidden'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // check whether path starts slash
|
|
|
|
|
+ newPagePath = pathUtils.addHeadingSlash(newPagePath);
|
|
|
|
|
+
|
|
|
await page.populateDataToShowRevision();
|
|
await page.populateDataToShowRevision();
|
|
|
const originTags = await page.findRelatedTagsById();
|
|
const originTags = await page.findRelatedTagsById();
|
|
|
|
|
|