This commit is contained in:
Géry Debongnie
2019-01-23 22:52:50 +01:00
parent 76fedae5a9
commit 88c5c06468
12 changed files with 83 additions and 79 deletions
+4 -4
View File
@@ -18,11 +18,11 @@ export function escape(str: string | number | undefined): string {
*/
export function htmlTrim(s: string): string {
let result = s.replace(/(^\s+|\s+$)/g, "");
if (s[0] === ' ') {
result = ' ' + result;
if (s[0] === " ") {
result = " " + result;
}
if (result !== ' ' && s[s.length - 1] === ' ') {
result = result + ' ';
if (result !== " " && s[s.length - 1] === " ") {
result = result + " ";
}
return result;
}