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

Add ES6 arrow function support to utils.clean #1176

Merged
merged 1 commit into from
Jul 11, 2014

Conversation

fitzgen
Copy link
Contributor

@fitzgen fitzgen commented Mar 29, 2014

No description provided.

@@ -209,7 +209,7 @@ exports.slug = function(str){
exports.clean = function(str) {
str = str
.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, '')
.replace(/^function *\(.*\) *{/, '')
.replace(/^function *\(.*\) *{|\(.*\) *=> *{?/, '')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... that regexp doesn't allow other whitespace characters (for example, tabs). They are pretty rare in the middle of the line, but it looks a bit incomplete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I just followed the trend, didn't want to rock the boat or distract from this pull request.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I agree with @rlidwka that using whitespace character matching would be cleaner (and I'd happily accept a PR doing just that).

However, for a PR focussing on something else I see why you chose not to do so yet, @fitzgen :)

@jonathanong
Copy link
Contributor

what's the context for this?

@fitzgen
Copy link
Contributor Author

fitzgen commented Jul 8, 2014

what's the context for this?

utils.clean is used to remove the function () { and } when showing the test source. It doesn't work with ES6 arrow functions, though. Hence, this PR.

jbnicolai pushed a commit that referenced this pull request Jul 11, 2014
Add ES6 arrow function support to utils.clean
@jbnicolai jbnicolai merged commit 85d1c60 into mochajs:master Jul 11, 2014
@jbnicolai
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants