Skip to content

Bug: endsWithSingleSpace fails on whitespace-only strings and technical debt in string.js #799

Description

@MrCodeBS

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

  1. Modify the regex in endsWithSingleSpace to /(?:[^\s]|^)\s$/ to handle whitespace-only strings appropriately.
  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions