0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 15:52:39 +00:00

Maximum title length set to 100 characters.

This commit is contained in:
G.Ambatte
2021-02-21 13:03:20 +13:00
parent 6a2e39355c
commit 9ee38ec7e3

View File

@@ -11,9 +11,15 @@ const Markdown = require('../shared/naturalcrit/markdown.js');
// });
// };
const MAX_TITLE_LENGTH = 100;
const getGoodBrewTitle = (text)=>{
const tokens = Markdown.marked.lexer(text);
return title = (tokens.find((token)=>token.type == 'heading' || token.type == 'paragraph') || { text: 'No Title' }).text;
let title = (tokens.find((token)=>token.type == 'heading' || token.type == 'paragraph') || { text: 'No Title' }).text;
if(title.length > MAX_TITLE_LENGTH) {
title = title.substr(0, MAX_TITLE_LENGTH);
}
return title;
};
const newBrew = (req, res)=>{
@@ -122,8 +128,6 @@ const newGoogleBrew = async (req, res, next)=>{
req.body = brew;
console.log(oAuth2Client);
const newBrew = await GoogleActions.newGoogleBrew(oAuth2Client, brew);
return res.status(200).send(newBrew);