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

RegExp literal fixes #264

Merged
merged 3 commits into from
Nov 13, 2016
Merged

RegExp literal fixes #264

merged 3 commits into from
Nov 13, 2016

Conversation

shinew
Copy link
Contributor

@shinew shinew commented Nov 11, 2016

See #263.

There's a comment I made in the code about the need to prettify let a = / /; into let a = /\t\;, which have the same behavior. This makes the generated literal more clear, at the cost of 1-3 extra characters per invisible newline character when minified. I'm not convinced this beautification is necessary since it's generated code anyway.

Thoughts?

@boopathi boopathi added the Tag: Bug Fix Pull Request fixes a bug label Nov 11, 2016
@kangax
Copy link
Member

kangax commented Nov 11, 2016

I think we shouldn't bother with "\t" similar to how we don't do this w. Babel literals and minified=true.

Does this work with backslash escapes?

new RegExp('https?:\\/\\/(?:[\\dA-Za-z\\-]+\\.)+[\\dA-Za-z\\-]+(?::\\d+)?\\/[^\\s]*')

@shinew
Copy link
Contributor Author

shinew commented Nov 12, 2016

Yeah, that case works I think.
Output string is: "var x = /https?:\\/\\/(?:[\\dA-Za-z\\-]+\\.)+[\\dA-Za-z\\-]+(?::\\d+)?\\/[^\\s]*/;", corresponding to the code:var x = /https?:\/\/(?:[\dA-Za-z\-]+\.)+[\dA-Za-z\-]+(?::\d+)?\/[^\s]*/;. Running 'https://github.com/babel/babili/pull/264'.replace(x, '') in the console returns "".

@kangax kangax merged commit a8d2add into babel:master Nov 13, 2016
@kangax
Copy link
Member

kangax commented Nov 13, 2016

Strange, I'm seeing test failure on travis — https://travis-ci.org/babel/babili/jobs/175548633 — but not locally

@kangax
Copy link
Member

kangax commented Nov 13, 2016

Actually, no there's failures locally too. @shinew could you please take a look when you get a chance.

@shinew
Copy link
Contributor Author

shinew commented Nov 14, 2016

My bad -- forgot to update test after restoring the \t literal.

@shinew shinew mentioned this pull request Nov 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tag: Bug Fix Pull Request fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants