From d70a7dbdc937415e15760dccf3bf79465a1e067f Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 15 Sep 2022 08:10:02 +0200 Subject: [PATCH] fix trim --- src/compiler/utils/patterns.ts | 2 ++ src/compiler/utils/trim.ts | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/utils/patterns.ts b/src/compiler/utils/patterns.ts index 2302be2edbcf..9429d47227ea 100644 --- a/src/compiler/utils/patterns.ts +++ b/src/compiler/utils/patterns.ts @@ -1,7 +1,9 @@ export const regex_whitespace = /\s/; export const regex_whitespaces = /\s+/; export const regex_starts_with_whitespace = /^\s/; +export const regex_starts_with_whitespaces = /^[ \t\r\n]*/; export const regex_ends_with_whitespace = /\s$/; +export const regex_ends_with_whitespaces = /[ \t\r\n]*$/; export const regex_only_whitespaces = /^\s+$/; export const regex_whitespace_characters = /\s/g; diff --git a/src/compiler/utils/trim.ts b/src/compiler/utils/trim.ts index d64ad25d3743..919a423d7f33 100644 --- a/src/compiler/utils/trim.ts +++ b/src/compiler/utils/trim.ts @@ -1,9 +1,9 @@ -import { regex_starts_with_whitespace, regex_ends_with_whitespace } from './patterns'; +import { regex_starts_with_whitespaces, regex_ends_with_whitespaces } from './patterns'; export function trim_start(str: string) { - return str.replace(regex_starts_with_whitespace, ''); + return str.replace(regex_starts_with_whitespaces, ''); } export function trim_end(str: string) { - return str.replace(regex_ends_with_whitespace, ''); + return str.replace(regex_ends_with_whitespaces, ''); }