fix(core): invalid feed fields (#9286)

Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com>
This commit is contained in:
Rongrong
2022-03-22 02:13:15 +08:00
committed by GitHub
parent fe775f5198
commit c48ca6bd5b
4 changed files with 40 additions and 1 deletions

View File

@@ -6,6 +6,18 @@ const toTitleCase = (str) =>
.map((word) => word.replace(word[0], word[0].toUpperCase()))
.join(' ');
const rWhiteSpace = /\s+/;
const rAllWhiteSpace = /\s+/g;
// collapse all whitespaces into a single space (like "white-space: normal;" would do), and trim
const collapseWhitespace = (str) => {
if (str && rWhiteSpace.test(str)) {
return str.replace(rAllWhiteSpace, ' ').trim();
}
return str;
};
module.exports = {
toTitleCase,
collapseWhitespace,
};