aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Bazon <mihai.bazon@gmail.com>2015-11-09 13:15:20 +0200
committerMihai Bazon <mihai.bazon@gmail.com>2015-11-09 13:15:20 +0200
commit18d37ac761d8f9bb3904d447ddbb0ac471fc161c (patch)
treed5ed662004357647bc6aa63c260ee6c51d04d031
parent63d35f8f6db6d90d6142132d2d5f0bd5d3d698aa (diff)
downloadtracifyjs-18d37ac761d8f9bb3904d447ddbb0ac471fc161c.tar.gz
tracifyjs-18d37ac761d8f9bb3904d447ddbb0ac471fc161c.zip
Fix parsing invalid input
i.e. `x = 1.xe` — because parseFloat("1.xe") returns 1, this parsed as `x = 1`. Ref #857
-rw-r--r--lib/parse.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 4c548a26..cb35118a 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -182,7 +182,8 @@ function parse_js_number(num) {
} else if (RE_OCT_NUMBER.test(num)) {
return parseInt(num.substr(1), 8);
} else {
- return parseFloat(num);
+ var val = parseFloat(num);
+ if (val == num) return val;
}
};