| 92 | } |
| 93 | |
| 94 | export const jsClean = (str: string) => { |
| 95 | // Clean all non-alphanumberic values except for dashes |
| 96 | const cleanString = str.replace(/[^a-zA-Z0-9-]/g, ""); |
| 97 | |
| 98 | // Capitalize the letter following a dash |
| 99 | const capitalizedAfterDash = cleanString.replace( |
| 100 | /-([a-zA-Z])/g, |
| 101 | (_, letter) => letter.toUpperCase() |
| 102 | ); |
| 103 | |
| 104 | // Remove all dashes and non-alphanumeric characters |
| 105 | return capitalizedAfterDash.replace(/[^a-zA-Z0-9]/g, ""); |
| 106 | }; |
| 107 | |
| 108 | export const upperFirst = (str: string) => |
| 109 | str.charAt(0).toUpperCase() + str.slice(1); |