Skip to content

Commit

Permalink
fix: handle possible index out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
davidAtInleague committed Apr 24, 2024
1 parent 94a8066 commit 14e0011
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions models/Str.cfc
Expand Up @@ -61,6 +61,11 @@ component singleton {
function capitalize( str, preserveCase = false ) {
var strArray = listToArray( preserveCase ? str : lCase( str ), "" );
var firstCharacterIndex = reFind( "\w", arguments.str );

if ( firstCharacterIndex == 0 ) {
return str;
}

strArray[ firstCharacterIndex ] = uCase( strArray[ firstCharacterIndex ] );
return arrayToList( strArray, "" );
}
Expand Down

0 comments on commit 14e0011

Please sign in to comment.