node.inflection icon indicating copy to clipboard operation
node.inflection copied to clipboard

Titleize does not work on words with dashes

Open corroded opened this issue 7 years ago • 2 comments

Example:

inflection.titleize("x-men:-the-last-stand")
"X-Men:-the-Last-Stand"

For comparison on Rails 4.2:

Loading development environment (Rails 4.2.7.1)
irb(main):001:0> ActiveSupport::Inflector.titleize("x-men:-the-last-stand")
=> "X Men: The Last Stand"

And Rails 5:

Loading development environment (Rails 5.1.1)
irb(main):001:0> ActiveSupport::Inflector.titleize("x-men:-the-last-stand")
=> "X Men: The Last Stand"

corroded avatar Jun 13 '17 06:06 corroded

I was expecting camelize and humanize to work the same but I also experience that it doesn't affect dasherized words:

camelize('hello-world') === 'Hello-world'

Is this also expected?

CristhianMotoche avatar Nov 30 '23 14:11 CristhianMotoche

I would also expect underscore to replace dasherized words but it doesn't:

underscore('hello-world') === 'hello-world'

Would it make sense to make underscore replace - with _?

CristhianMotoche avatar Nov 30 '23 15:11 CristhianMotoche