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:
commit
a990cd163d
1 changed files with 6 additions and 1 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue