mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
Refactor normalizeValue function in PerformerResult component for improved value handling.
- Enhanced the normalizeValue function to handle numeric-like strings, converting them to numbers when applicable. - Maintained existing functionality for trimming and lowercasing non-numeric strings, ensuring consistent value normalization.
This commit is contained in:
parent
7a87e15f41
commit
db7164d254
1 changed files with 14 additions and 3 deletions
|
|
@ -21,9 +21,20 @@ interface IPerformerDeltaRow {
|
|||
}
|
||||
|
||||
const normalizeValue = (value: unknown) =>
|
||||
String(value ?? "")
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
(() => {
|
||||
const text = String(value ?? "").trim();
|
||||
if (!text) return "";
|
||||
|
||||
const isNumericLike = /^[-+]?(?:\d+\.?\d*|\.\d+)$/.test(text);
|
||||
if (isNumericLike) {
|
||||
const numeric = Number(text);
|
||||
if (!Number.isNaN(numeric)) {
|
||||
return String(numeric);
|
||||
}
|
||||
}
|
||||
|
||||
return text.toLowerCase();
|
||||
})();
|
||||
|
||||
const toStringOrNull = (value: unknown) => {
|
||||
if (value === null || value === undefined) return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue