Fixed zeroes being trimmed for non-rug numbers

This commit is contained in:
bakk 2021-05-15 16:15:25 +02:00
parent 277b1ed4c0
commit d5c991ffdf
3 changed files with 11 additions and 7 deletions

2
Cargo.lock generated
View File

@ -127,7 +127,7 @@ dependencies = [
[[package]]
name = "kalk"
version = "1.4.3"
version = "1.4.4"
dependencies = [
"lazy_static",
"regex",

View File

@ -1,6 +1,6 @@
[package]
name = "kalk"
version = "1.4.3"
version = "1.4.4"
authors = ["PaddiM8"]
edition = "2018"
readme = "README.md"

View File

@ -51,11 +51,15 @@ impl KalkNum {
#[wasm_bindgen(js_name = toString)]
pub fn to_string(&self) -> String {
self.value
.to_string()
.trim_end_matches('0')
.trim_end_matches('.')
.to_string()
let string_value = self.value.to_string();
if string_value.contains(".") {
string_value
.trim_end_matches('0')
.trim_end_matches('.')
.to_string()
} else {
string_value
}
}
#[wasm_bindgen(js_name = toStringBig)]