From 48b37f127fb44b787ae6c0710982d7949b14454f Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 6 Mar 2017 17:40:15 +0000 Subject: Update `titlelize` regex to allow apostrophes In 4b685aa the regex in `titlelize` was updated to not match apostrophes to better reflect the nature of the transformation. Unfortunately this had the side effect of breaking capitalization on the first word of a sub-string, e.g: >> "This was 'fake news'".titleize => "This Was 'fake News'" This is fixed by extending the look-behind to also check for a word character on the other side of the apostrophe. Fixes #28312. --- activesupport/lib/active_support/inflector/methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/inflector') diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 8ccb735c6d..51c221ac0e 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -161,7 +161,7 @@ module ActiveSupport # titleize('TheManWithoutAPast') # => "The Man Without A Past" # titleize('raiders_of_the_lost_ark') # => "Raiders Of The Lost Ark" def titleize(word) - humanize(underscore(word)).gsub(/\b(?