Normalize spaced RNG draw costs
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s
This commit is contained in:
parent
f8231c748f
commit
25889a23ba
2 changed files with 2 additions and 1 deletions
|
|
@ -317,6 +317,7 @@ test("rng simulator preserves rate precision and compacts storage", () => {
|
|||
assert.equal(normalized.history, undefined);
|
||||
assert.equal(normalizeCostString("0"), "");
|
||||
assert.equal(normalizeCostString("0012,500"), "12.500");
|
||||
assert.equal(normalizeCostString("100 000 000"), "100000000");
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalizeRngSimulatorData({})), null);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalized).rates[0].costPerDraw, undefined);
|
||||
assert.equal(compactModuleDataForStorage("rngSimulator", normalized).rates[1].costPerDraw, "12.500");
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export function normalizeRateString(value, fallback = RNG_SIMULATOR_DEFAULT_RATE
|
|||
}
|
||||
|
||||
export function normalizeCostString(value, fallback = "") {
|
||||
const raw = String(value ?? "").trim().replace(",", ".");
|
||||
const raw = String(value ?? "").trim().replace(/[\s\u00a0]/g, "").replace(",", ".");
|
||||
if (!raw) return fallback;
|
||||
if (!/^\d*(?:\.\d+)?$/.test(raw) || raw === ".") return fallback;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue