Commit 95535aa3 authored by Nick's avatar Nick

fix: prevent dots and spaces in page path during create

parent 2e0f861f
......@@ -129,6 +129,10 @@ module.exports = {
message: 'Page content cannot be empty.',
code: 6004
}),
PageIllegalPath: CustomError('PageIllegalPath', {
message: 'Page path cannot contains illegal characters.',
code: 6005
}),
PageNotFound: CustomError('PageNotFound', {
message: 'This page does not exist.',
code: 6003
......
......@@ -213,6 +213,10 @@ module.exports = class Page extends Model {
* @returns {Promise} Promise of the Page Model Instance
*/
static async createPage(opts) {
if (opts.path.indexOf('.') >= 0 || opts.path.indexOf(' ') >= 0) {
throw new WIKI.Error.PageIllegalPath()
}
const dupCheck = await WIKI.models.pages.query().select('id').where('localeCode', opts.locale).where('path', opts.path).first()
if (dupCheck) {
throw new WIKI.Error.PageDuplicateCreate()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment