Files
ota-admin-portal/src/utils/strings.js
John Wu 19bc054343 CEC-3912 VIN input (#293)
* CEC-3912 VIN input

* Revert
2023-03-16 15:13:47 -07:00

14 lines
382 B
JavaScript

export function trimIfMoreThan(maybeString, maxLength = 20, sfx = "") {
if (typeof maybeString == "string" && maybeString !== "") {
let toAppSfx = sfx
let toTrimLnth = maxLength - toAppSfx.length
if (maybeString.length <= maxLength) {
toAppSfx = ""
toTrimLnth = maxLength
}
return maybeString.substring(0, toTrimLnth) + toAppSfx
}
return ""
}