Skip to content

minify edits the regex (incorrectly) #137

@CptMeatball

Description

@CptMeatball

When minifying a JS file with a (certain) regex, it changes the regex to a regex that does something different.

minify file.js > min.js

The following regex:

const regex = /^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,}$/i;

is converted to:

const regex = /^([\w+-]+\.?)*[\w+-]@([\da-z][\da-z-]*\.)+[a-z]{2}$/i;

Running terser file.js -o min.js --compress --mangle (terser@5.31.3 in node@22.11) directly does not produce the same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions