Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid pattern with unescaped dot fails to rewrite #33

Open
juliangoacher opened this issue Oct 8, 2019 · 1 comment
Open

Valid pattern with unescaped dot fails to rewrite #33

juliangoacher opened this issue Oct 8, 2019 · 1 comment

Comments

@juliangoacher
Copy link

The rewritePattern function generates an error when passed a regex pattern containing an unescaped dot within an alternatives group.

For example, the following pattern:

    /(x.x|x)/

Fails to rewrite in the following code:

const regex = /(x.x|x)/
const pattern = regex.toString()
rewritePattern(pattern)

And instead generates the following error:

Error: Invalid node type: dot; expected types: /^(?:anchor|characterClass|characterClassEscape|empty|group|quantifier|reference|unicodePropertyEscape|value)$/

The error goes away if the dot is escaped:

    /(x\.x|x)/

But of course this changes the meaning of the regex.

The problem is seen in the current regexpu version (4.6.0) but doesn't seem to exist in the previous version (tested 4.5.4).

@nicolo-ribaudo
Copy link
Collaborator

Fixed by bnjmnt4n/regjsgen#13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants