Skip to content

.replace replacing removed code #223

Closed

Description

@fisker
> new (require('magic-string'))('00').remove(0, 1).replace('0', '1').toString()
'10'

Shouldn't the result be 1?

Activity

  1. antfu commented on Sep 22, 2022

    @antfu
    Collaborator

    .replace matches against the original string, which is a document caveat. I am not sure if there is a way to improve that, if so I am open for PR.

  2. fisker commented on Sep 22, 2022

    @fisker
    ContributorAuthor

    I'm not sure exactly how it works, I generated a new MagicString before replacing for now. prettier/prettier@77ac062

  3. Tal500 commented on Oct 4, 2022

    @Tal500
    Contributor

    .replace matches against the original string, which is a document caveat. I am not sure if there is a way to improve that, if so I am open for PR.

    Is it problematic to get as parameter if the user wants to perform the search on the original string or not?

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions