Shopify / javascript

The home for all things JavaScript at Shopify.
MIT License
253 stars 38 forks source link

Decaf: investigate mangled block regex #92

Closed GoodForOneFare closed 8 years ago

GoodForOneFare commented 8 years ago

While reviewing the string cleanup PR, I'm seeing what looks like a broken regex conversion. It may not be an issue, but I'm trying to concentrate on other stuff right now.

design_model/live-colors.coffee

  commentRegex: (key) ->
    /// \/\*\!setting\.[\"\s]*#{Strings.escapeRegexpString(key)}[\"\s]*\{\*\/([^\}]*)\/\*\}\*\/ ///g

Before string cleanup, this translates to

  return RegExp(('\\/\\\\*\\\\!setting\\\\.[\\"\\\\s]*' + (Strings.escapeRegexpString(key)) + '[\\"\\\\s]*\\\\{\\\\*\\\\/([^\\\\}]*)\\\\/\\\\*\\\\}\\\\*\\\\/'), 'g');

After string cleanup, it translates to

return RegExp(('\\/\\\\*\\\\!setting\\\\.["\\\\s]*' + (Strings.escapeRegexpString(key)) + '["\\\\s]*\\\\{\\\\*\\\\/([^\\\\}]*)\\\\/\\\\*\\\\}\\\\*\\\\/'), 'g');
GoodForOneFare commented 8 years ago

Confirmed that this was never an accurate CS=>JS conversion. I'll add details to the string escaping PR and let Chris decide if it's a separate issue.