mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
fix(core): invalid feed fields (#9286)
Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com>
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user