EricSmekens / jsep

JavaScript Expression Parser
http://ericsmekens.github.io/jsep/
MIT License
836 stars 136 forks source link

Regex plugin does not parse slashes #214

Closed mcdamo closed 2 years ago

mcdamo commented 2 years ago

The regex plugin does not appear to support slashes within the regex, even if they are escaped.

Some simple regex strings that should parse:

'/\\//',     // => /\//
'/[\\/]/',   // => /[\/]/
'/\\\\\\//', // => /\\\//
'/[/]/',     // => /[/]/

These presently throw exception Invalid regular expression:

The plugin halts at the first character match of /, ignoring escaping or nesting of parenthesis.

6utt3rfly commented 2 years ago

Thanks for reporting @mcdamo ! Looks like that was definitely an oversight on initial implementation, so I've created a PR to fix it, using your examples plus a few more edge cases.

mcdamo commented 2 years ago

Thanks @6utt3rfly for the quick response. That looks like an elegant solution.

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version @jsep-plugin/regex-v1.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: