update view message
This commit is contained in:
parent
279e1a1785
commit
45c2093d05
|
|
@ -14,8 +14,19 @@ function isTextInFormat(text: string) {
|
|||
return dateRegex.test(date) && productCodeRegex.test(productCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Chuẩn hoá text: gộp nhiều dòng trống liên tiếp thành 1 dòng trống duy nhất
|
||||
*/
|
||||
export function normalizeBlankLines(text: string): string {
|
||||
return text.replace(/\n\s*\n+/g, '\n\n');
|
||||
}
|
||||
|
||||
export function formatTextIfValid(text: string) {
|
||||
if (!isTextInFormat(text)) return text; // Không đúng format thì trả về nguyên bản
|
||||
if (!isTextInFormat(text)) {
|
||||
const newText = normalizeBlankLines(text);
|
||||
|
||||
return newText;
|
||||
} // Không đúng format thì trả về nguyên bản
|
||||
|
||||
const lines = text
|
||||
.split('\n')
|
||||
|
|
|
|||
Loading…
Reference in New Issue