Merge pull request #35175 from DhavalGala999/fix-shorten-number-null-length-error

fix(utils): safely handle null/NaN/empty in shorten_number
This commit is contained in:
Ejaaz Khan 2026-01-22 16:55:41 +05:30 committed by GitHub
commit a990cd163d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1606,8 +1606,13 @@ Object.assign(frappe.utils, {
* max_no_of_decimals - max number of decimals of the shortened number
*/
// return empty for null, undefined, or empty string
if (!number || isNaN(number)) {
return "";
}
// return number if total digits is lesser than min_length
const len = String(number).match(/\d/g).length;
const len = String(number).match(/\d/g)?.length || 0;
if (len < min_length) {
return number.toString();
}