Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
1d8f1f50
You need to sign in or sign up before continuing.
Commit
1d8f1f50
authored
Aug 26, 2019
by
Nick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: prevent empty page content
parent
518602b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
error.js
server/helpers/error.js
+4
-0
pages.js
server/models/pages.js
+9
-0
No files found.
server/helpers/error.js
View file @
1d8f1f50
...
...
@@ -125,6 +125,10 @@ module.exports = {
message
:
'Cannot create this page because an entry already exists at the same path.'
,
code
:
6002
}),
PageEmptyContent
:
CustomError
(
'PageEmptyContent'
,
{
message
:
'Page content cannot be empty.'
,
code
:
6004
}),
PageNotFound
:
CustomError
(
'PageNotFound'
,
{
message
:
'This page does not exist.'
,
code
:
6003
...
...
server/models/pages.js
View file @
1d8f1f50
...
...
@@ -182,6 +182,10 @@ module.exports = class Page extends Model {
throw
new
WIKI
.
Error
.
PageDuplicateCreate
()
}
if
(
!
opts
.
content
||
_
.
trim
(
opts
.
content
).
length
<
1
)
{
throw
new
WIKI
.
Error
.
PageEmptyContent
()
}
await
WIKI
.
models
.
pages
.
query
().
insert
({
authorId
:
opts
.
authorId
,
content
:
opts
.
content
,
...
...
@@ -230,6 +234,11 @@ module.exports = class Page extends Model {
if
(
!
ogPage
)
{
throw
new
Error
(
'Invalid Page Id'
)
}
if
(
!
opts
.
content
||
_
.
trim
(
opts
.
content
).
length
<
1
)
{
throw
new
WIKI
.
Error
.
PageEmptyContent
()
}
await
WIKI
.
models
.
pageHistory
.
addVersion
({
...
ogPage
,
isPublished
:
ogPage
.
isPublished
===
true
||
ogPage
.
isPublished
===
1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment