Skip to content

SyntaxError: Invalid regular expression: missing / #43

@sweh

Description

@sweh

Hi,

when minifying the current moment.js File [1], I get a SyntaxError in the minified version created by jsmin. The source file contains the following code:

        this._dayOfMonthOrdinalParseLenient = new RegExp(
            (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
                '|' +
                /\d{1,2}/.source
        );

which is minified to

this._config=config;this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+
'|'+/
\d{1,2}/.source);}

If I remove the new lines, the generated minified JavaScript is valid.

Why are those newlines preserved anyways?

Cheers,
Sebastian

[1] https://momentjs.com/downloads/moment.js

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