diff --git a/.eslintrc.js b/.eslintrc.js index 6d763454c..e8618b8c7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,7 @@ module.exports = { root : true, parserOptions : { - ecmaVersion : 9, + ecmaVersion : 2021, sourceType : 'module', ecmaFeatures : { jsx : true diff --git a/server/homebrew.api.js b/server/homebrew.api.js index e88a3ef88..02f88c937 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -11,9 +11,12 @@ 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; + return (tokens.find((token)=>token.type == 'heading' || token.type == 'paragraph')?.text || 'No Title') + .slice(0, MAX_TITLE_LENGTH); }; const newBrew = (req, res)=>{