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

Regex in <script> function breaks compiler #2369

MartinMuzatko opened this issue May 24, 2017 · 0 comments

Regex in <script> function breaks compiler #2369

MartinMuzatko opened this issue May 24, 2017 · 0 comments


Copy link

@MartinMuzatko 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:


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?

  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
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.