Skip to content

Commit

Permalink
support fields with numbers in dynamic bc
Browse files Browse the repository at this point in the history
  • Loading branch information
johrstrom committed Apr 10, 2024
1 parent 067996d commit 963aeda
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/dashboard/app/javascript/dynamic_forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ function snakeCaseWords(str) {
snakeCase += c.toLowerCase();
} else if(c == c.toUpperCase() && isNaN(c)) {
const nextIsUpper = (index + 1 !== str.length) ? str[index + 1] === str[index + 1].toUpperCase() : true;
if (str[index-1] === '_' || nextIsUpper) {
const nextIsNum = !isNaN(str[index + 1]);
if ((str[index-1] === '_' || nextIsUpper) && !nextIsNum) {
snakeCase += c.toLowerCase();
} else {
snakeCase += `_${c.toLowerCase()}`;
Expand Down

0 comments on commit 963aeda

Please sign in to comment.