nbubna/Case

First and last word in title should always be capitalized

zanemcca opened this issue · 5 comments

I noticed that the first and last words from a Case.title call are not uppercased if they are a small word. I think this should be dealt with internally.
This is a pretty good implementation of title casing for reference.

Fixed in version 1.3.1

Thanks for the catch!

Thanks for the quick fix @nbubna. I noticed that the last word is also not capitalized if it is small. You could fix it up with a little bit of post-processing like I have done with this workaround.

// Capitalize the first character of the last word
var lastSpaceIdx = title.lastIndexOf(' ');
if(lastSpaceIdx > -1) {
   var lastWord = title.substr(lastSpaceIdx + 1); 
   if(lastWord.length > 0) {
      title = title.slice(0, lastSpaceIdx + 1) + lastWord.charAt(0).toUpperCase() + lastWord.substr(1); 
   }   
} 

Ah, should've have thought of that...

Ok, should be taken care of in 1.3.2.

Thanks a lot @nbubna