Skip to content

Empty RegExp causes crash #2

@samhh

Description

@samhh

The following code is causing a crash/hang:

import strReplaceAsArr from 'string-replace-to-array'

const addHighlightMarkup = ({ str, textFilter }) =>
  strReplaceAsArr(
    str,
    new RegExp(textFilter, 'ig'),
    match => <span className="highlighted-text">{match}</span>
  )

...when textFilter is an empty string. This behaviour is inconsistent with String.prototype.replace which will accept/ignore an empty string.

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