Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions packages/nocodb-sdk/src/lib/numberUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ export const numberize = (value?: string | number) => {
if (value === undefined || value === null) {
return value as undefined;
}

if (typeof value === 'number') {
return value as number;
} else {
const result = parseInt(value);
if (isNaN(result)) {
return undefined;
}
return result;
}

const result = parseInt(value);
Comment on lines +12 to +13
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseInt без radix - потенциальный баг (parseInt('0x10') === 16). Передай радикс явно: parseInt


if (isNaN(result)) {
return undefined;
}
Comment on lines +14 to +17
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseInt вернёт 123 - пройдёт мимо isNaN и вернёт частично распарсенное число. Замени на Number или добавь pre-check /^-?\d+$/


return result;
};

export const roundTo = (num: unknown, precision = 1) => {
Expand Down