Extracted out the commonly used line break regex

This commit extract the commonly used /br\s*\/?>/gi regex to common.js,
in order to keep the code more DRY.
This commit is contained in:
Danny Shemesh
2020-04-23 07:17:09 +03:00
parent 10fdc45dea
commit 22dd50a047
7 changed files with 22 additions and 13 deletions

View File

@@ -25,8 +25,10 @@ export const sanitizeText = (text, config) => {
return txt;
};
export const lineBreakRegex = /<br\s*\/?>/gi;
const breakToPlaceholder = s => {
return s.replace(/<br\s*\/?>/gi, '#br#');
return s.replace(lineBreakRegex, '#br#');
};
const placeholderToBreak = s => {
@@ -35,5 +37,6 @@ const placeholderToBreak = s => {
export default {
getRows,
sanitizeText
sanitizeText,
lineBreakRegex
};