mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-24 00:11:29 +00:00
Added in full test coverage of current spec
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
const _ = require('lodash');
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
getGoodBrewTitle : (text) => {
|
||||
getGoodBrewTitle : (text = '') => {
|
||||
const titlePos = text.indexOf('# ');
|
||||
if(titlePos !== -1){
|
||||
const ending = text.indexOf('\n', titlePos);
|
||||
return text.substring(titlePos + 2, ending);
|
||||
let ending = text.indexOf('\n', titlePos);
|
||||
ending = (ending == -1 ? undefined : ending);
|
||||
return text.substring(titlePos + 2, ending).trim();
|
||||
}else{
|
||||
return _.find(text.split('\n'), (line)=>{
|
||||
return (_.find(text.split('\n'), (line)=>{
|
||||
return line;
|
||||
});
|
||||
}) || '').trim();
|
||||
}
|
||||
},
|
||||
replaceByMap : (text, mapping) => {
|
||||
|
||||
Reference in New Issue
Block a user