mirror of https://github.com/status-im/codimd.git
Merge pull request #966 from SISheogorath/fix/documentLength
Fix document length limit on post
This commit is contained in:
commit
55f7568985
|
@ -32,6 +32,9 @@ var response = {
|
||||||
errorBadRequest: function (res) {
|
errorBadRequest: function (res) {
|
||||||
responseError(res, '400', 'Bad Request', 'something not right.')
|
responseError(res, '400', 'Bad Request', 'something not right.')
|
||||||
},
|
},
|
||||||
|
errorTooLong: function (res) {
|
||||||
|
responseError(res, '413', 'Payload Too Large', 'Shorten your note!')
|
||||||
|
},
|
||||||
errorInternalError: function (res) {
|
errorInternalError: function (res) {
|
||||||
responseError(res, '500', 'Internal Error', 'wtf.')
|
responseError(res, '500', 'Internal Error', 'wtf.')
|
||||||
},
|
},
|
||||||
|
@ -145,7 +148,12 @@ function responseCodiMD (res, note) {
|
||||||
|
|
||||||
function newNote (req, res, next) {
|
function newNote (req, res, next) {
|
||||||
var owner = null
|
var owner = null
|
||||||
var body = req.body ? req.body : ''
|
var body = ''
|
||||||
|
if (req.body && req.body.length > config.documentMaxLength) {
|
||||||
|
return response.errorTooLong(res)
|
||||||
|
} else {
|
||||||
|
body = req.body
|
||||||
|
}
|
||||||
body = body.replace(/[\r]/g, '')
|
body = body.replace(/[\r]/g, '')
|
||||||
if (req.isAuthenticated()) {
|
if (req.isAuthenticated()) {
|
||||||
owner = req.user.id
|
owner = req.user.id
|
||||||
|
|
Loading…
Reference in New Issue