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

Regex in <script> function breaks compiler #2369

Closed
MartinMuzatko opened this Issue May 24, 2017 · 0 comments

Comments

Projects
None yet
3 participants
@MartinMuzatko
Member

MartinMuzatko commented May 24, 2017

Help us to manage our issues by answering the following:

  1. Describe your issue:

Hello! I found an issue with regex, when written like this: /.../ instead of new RegExp('...').
It looks like an escaped / slash at the end of a regex literal breaks the compiler.

While in the browser I get this error:

VM422 my-tag.html.js:5 Uncaught SyntaxError: Invalid regular expression: missing /

Webpack is showing how the tag is interpreted:

image

While the original code says:

this.getSpaceNameForLink = link => {
    var x = ('display/eeeeh').match(/display\/(\w+)\//)[1]

So it looks like I hit a dead spot in the riot compiler, where the rest of the line is removed.

The current workaround is to use RegExp

var x = ('display/eeeeh').match(new RegExp('display/(\\w+)/'))[1]
  1. Can you reproduce the issue?

http://plnkr.co/edit/IOcOemWby6bzaGssWOWr?p=preview

  1. On which browser/OS does the issue appear?

Chrome 58/Mac OS X El Capitan

  1. Which version of Riot does it affect?
  • Latest (3.5.1)
  1. How would you tag this issue?
  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment