Description
We encountered an issue where endsWithSingleSpace in src/util/string.js evaluates incorrectly when handling text comprised entirely of whitespace.
Currently, it uses /\S+\s{1}$/ which requires at least one non-whitespace character to precede the trailing space. This causes it to return false for inputs like " ", avoiding proper substitution in dependent modules such as dispatcher.js.
In addition, there are outstanding TODO items in string.js that requested refactoring custom string methods (trim, trimRight, trimLeft, isString) to use lodash methods instead.
Proposed Solution
- Modify the regex in
endsWithSingleSpace to /(?:[^\s]|^)\s$/ to handle whitespace-only strings appropriately.
- Substitute the custom utility methods in
src/util/string.js with their lodash equivalents.
A PR addressing these issues has already been opened at #798.
Description
We encountered an issue where
endsWithSingleSpaceinsrc/util/string.jsevaluates incorrectly when handling text comprised entirely of whitespace.Currently, it uses
/\S+\s{1}$/which requires at least one non-whitespace character to precede the trailing space. This causes it to returnfalsefor inputs like" ", avoiding proper substitution in dependent modules such asdispatcher.js.In addition, there are outstanding
TODOitems instring.jsthat requested refactoring custom string methods (trim,trimRight,trimLeft,isString) to uselodashmethods instead.Proposed Solution
endsWithSingleSpaceto/(?:[^\s]|^)\s$/to handle whitespace-only strings appropriately.src/util/string.jswith theirlodashequivalents.A PR addressing these issues has already been opened at #798.