mirror of
https://gitlab.com/RemixDev/deemix-js.git
synced 2024-12-29 10:56:18 +00:00
Merge pull request 'Correctly Capatilize After Opening Bracket' (#8) from Jera/deemix-js:jera-patch-1 into main
Reviewed-on: https://git.freezer.life/RemixDev/deemix-js/pulls/8
This commit is contained in:
commit
a2eff225f3
|
@ -25,7 +25,13 @@ function changeCase(txt, type){
|
|||
case 'upper': return txt.toUpperCase()
|
||||
case 'start':
|
||||
txt = txt.split(" ")
|
||||
for (let i = 0; i < txt.length; i++) txt[i] = txt[i][0].toUpperCase() + txt[i].substr(1).toLowerCase()
|
||||
for (let i = 0; i < txt.length; i++) {
|
||||
if (bracket = ['(', '{', '['].some(bracket => txt[i].startsWith(bracket))) {
|
||||
txt[i] = txt[i][0] + txt[i][1].toUpperCase() + txt[i].substr(2).toLowerCase()
|
||||
} else {
|
||||
txt[i] = txt[i][0].toUpperCase() + txt[i].substr(1).toLowerCase()
|
||||
}
|
||||
}
|
||||
return txt.join(" ")
|
||||
case 'sentence': return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase()
|
||||
default: return txt
|
||||
|
|
Loading…
Reference in a new issue