Skip to content

chore(web): TransformUtils.insertWhitespace seems convoluted #7232

@mcdurdin

Description

@mcdurdin

This seems a little convoluted.

  • I'm really not sure exactly what we are testing here. It seems like you are looking for insert.match(/[\u0009...]$/)? Is it intended to match having a single whitespace character on the end of the text? If so, then the function name is not very clear. If not, then AFAICT the function is not correct.

  • i modifier should not be necessary on the regex -- there's no case to be insensitive about 🤣.

  • Can we use a character class for the regex match rather than a set of characters? (e.g. insert.match(/[\p{Z}\r\n]$/u). Note Chrome 50+ though (so we could have the shorter regex as a comment if we can't use it for back-compat reasons).

  • Finally, can we have a javadoc comment rather than the in-function comment?

Originally posted by @mcdurdin in #7205 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions