Take sats as whole numbers in the browser too
This commit is contained in:
1 parent
d12df91acc
commit
2bc257004d
1 file changed
+8
-9
+8
-9
@@ -85,18 +85,17 @@
|
||||
return parts[2] + "." + parts[1] + "." + parts[0];
|
||||
}
|
||||
|
||||
/* Whole sats, with spaces allowed as thousands separators. Anything carrying
|
||||
a decimal separator gives null, like the server does. */
|
||||
function parseSats(text) {
|
||||
var cleaned = String(text === null || text === undefined ? "" : text)
|
||||
.split(NARROW_SPACE).join("")
|
||||
.split(" ").join("")
|
||||
.replace(",", ".");
|
||||
if (!/^\d*(\.\d{0,8})?$/.test(cleaned) || cleaned === "" || cleaned === ".") {
|
||||
var cleaned = String(text === null || text === undefined ? "" : text);
|
||||
THOUSANDS_SEPARATORS.forEach(function (separator) {
|
||||
cleaned = cleaned.split(separator).join("");
|
||||
});
|
||||
if (!/^-?\d+$/.test(cleaned)) {
|
||||
return null;
|
||||
}
|
||||
var parts = cleaned.split(".");
|
||||
var whole = parts[0] === "" ? "0" : parts[0];
|
||||
var fraction = (parts[1] || "").padEnd(8, "0");
|
||||
return Number(whole) * 100000000 + Number(fraction);
|
||||
return Number(cleaned);
|
||||
}
|
||||
|
||||
/* The stored type names and what the owner sees, docs/spec.md section 7.3. */
|
||||
|
||||
Reference in new issue
Block a user