mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Refactored line parsing to use regex
Was having issues debugging the index issue, and regex cleans it up a little
This commit is contained in:
parent
f8f96b49db
commit
c681b8e9be
@ -6,22 +6,21 @@ module.exports.filterEmojiCommits = (content) => {
|
||||
throw new Error('Expected array of strings.');
|
||||
}
|
||||
|
||||
content = content.filter(function (line, index, obj) {
|
||||
const sqbracket = line.substring(line.indexOf('['), line.indexOf(']') + 1);
|
||||
const rdbracket = line.substring(line.indexOf('('), line.indexOf(')') + 2);
|
||||
const contributor = line.substring(line.lastIndexOf('-') - 1, line.length);
|
||||
|
||||
// NOTE: modify original line
|
||||
line = line.replace(sqbracket, '');
|
||||
line = line.replace(rdbracket, '');
|
||||
line = line.replace(contributor, '');
|
||||
obj[index] = line;
|
||||
const timestamp = /^[0-9]{10} /;
|
||||
const separator = /^\* /;
|
||||
const hash = /^\[[0-9a-f]{9}\]/;
|
||||
const url = /^\(https?:\/\/[^)]+\) /;
|
||||
|
||||
return content.map((line) => {
|
||||
return '* ' + line
|
||||
.replace(timestamp, '')
|
||||
.replace(separator, '')
|
||||
.replace(hash, '')
|
||||
.replace(url, '');
|
||||
}).filter((line) => {
|
||||
const match = emojiRegex().exec(line);
|
||||
return match && match.index === 2;
|
||||
});
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
module.exports.checkMissingOptions = (options = {}, ...requiredFields) => {
|
||||
|
Loading…
Reference in New Issue
Block a user