Skip to content

replace plugin. "delimiters" config is broken by "escape" internal mutation #904

Closed

Description

@o-alexandrov

Expected Behavior

The delimiters option that is matching the default value should work the same

Actual Behavior

Unfortunately, the escape internal function that is supposed to escape RegExp string malfunctions.
So it's impossible to reproduce the current default behavior because of that.

Activity

  1. vegeta897 commented on Jul 31, 2021

    @vegeta897

    Any update on this?

    As you said, it's impossible to provide any special RegExp character (such as \b) because of this escape function.

    // Current escape function
    function escape(str) {
      return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
    }
    
    new RegExp(escape('\\b')) // Result: /\\b/
    new RegExp(escape('\b')) // Result: /�/
    // How do we get /\b/ ?

    Perhaps an option should be added that allows bypassing this function when creating the pattern?

  2. stale commented on Oct 1, 2021

    @stale

    Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ

  3. ef4 commented on Oct 28, 2021

    @ef4

    This is definitely a real bug. The delimiter option really should not run through escape.

  4. shellscape commented on Oct 29, 2021

    @shellscape
    Collaborator

    @ef4 please read the bot's message. If you'd like to open a PR for this, we'd be happy to reopen.

  5. o-alexandrov commented on Oct 29, 2021

    @o-alexandrov
    ContributorAuthor

    Btw, just to provide clarity why I didn't provide a PR for this issue.
    The default behavior in #903 resolved the need for me to pass custom delimiters.

  6. shellscape commented on Oct 29, 2021

    @shellscape
    Collaborator

    Appreciate the clarity. If someone picks this up, we'll reopen. Thanks again for the work on #903

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions