fix: remove trailing spaces before pushing signature (#7935)

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
Shivam Mishra
2023-09-19 13:29:44 +05:30
committed by GitHub
parent 9ba5adfd60
commit f8cb806548

View File

@@ -4,13 +4,26 @@
*/
export const SIGNATURE_DELIMITER = '--';
/**
* Remove trailing spaces from each line in a markdown text
* @param {string} markdownText
* @returns
*/
function removeTrailingSpaces(markdownText) {
return markdownText
.split('\n')
.map(line => line.replace(/\s+$/, ''))
.join('\n');
}
/**
* Trim the signature and remove all " \r" from the signature
* 1. Trim any extra lines or spaces at the start or end of the string
* 2. Converts all \r or \r\n to \f
*/
export function cleanSignature(signature) {
return signature.trim().replace(/\r\n?/g, '\n');
const cleaned = signature.trim().replace(/\r\n?/g, '\n');
return removeTrailingSpaces(cleaned);
}
/**