-
Notifications
You must be signed in to change notification settings - Fork 375
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
Fix underscore for single word #412
base: master
Are you sure you want to change the base?
Conversation
any feedback on this ? |
I will check it tomorrow |
I think if we change the behaviour of dasherize('oneAtATime'); // => 'one-at-a-time'
dasherize('ATime'); // => '-a-time'
dasherize('ONETime'); // => '-o-n-e-time'
underscored('oneAtATime'); // => 'one_at_a_time'
underscored('ATime'); // => 'a_time'
underscored('ONETime'); // => 'one_time' The only different should be that @epeli do you agree that we should change both functions to the behaviour proposed by @az7arul ? |
@@ -1,5 +1,5 @@ | |||
var trim = require('./trim'); | |||
|
|||
module.exports = function underscored(str) { | |||
return trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase(); | |||
return trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/([A-Z\d]+)([A-Z][a-z])/,'$1_$2').replace(/[-\s]+/g, '_').toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not have to be global (test case please)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup it needs to be global
63450a0
to
996afda
Compare
No description provided.