From 614d89ddddbde7c6b9bf09923cd0b1319f49727d Mon Sep 17 00:00:00 2001 From: Konstantinos Bairaktaris Date: Sun, 26 Jun 2022 15:48:26 +0300 Subject: [PATCH] Fix small inconsistencies in source strings --- packages/cli/src/api/parsers/babel.js | 2 +- packages/react/src/utils/toStr.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/api/parsers/babel.js b/packages/cli/src/api/parsers/babel.js index 99a6d4f6..3667c202 100644 --- a/packages/cli/src/api/parsers/babel.js +++ b/packages/cli/src/api/parsers/babel.js @@ -73,7 +73,7 @@ function toStr(children, counter = 0) { } } else if (child.type === 'JSXText') { // Child is not a React element, append as-is - const chunk = child.value.trim(); + const chunk = child.value.trim().replace(/\s+/g, ' '); if (chunk) { result.push(chunk); } } else if ( child.type === 'JSXExpressionContainer' diff --git a/packages/react/src/utils/toStr.js b/packages/react/src/utils/toStr.js index 1738e912..7da07fd9 100644 --- a/packages/react/src/utils/toStr.js +++ b/packages/react/src/utils/toStr.js @@ -64,7 +64,7 @@ export function toStr(children, counter = 0) { // Child is not a React element, append as-is /* eslint-disable no-lonely-if */ if (typeof child === 'string' || child instanceof String) { - const chunk = child.trim(); + const chunk = child.trim().replace(/\s+/g, ' '); if (chunk) { result.push(chunk); } } else { result.push(child);