Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/scratch-vm/src/util/cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@
return true;
} else if (typeof val === 'string') {
// If it contains a decimal point, don't consider it an int.
return val.indexOf('.') < 0;
if (val.toLowerCase().split('e').length === 2) {
return Number(val) === parseInt(Number(val), 10);
} else {

Check failure on line 172 in packages/scratch-vm/src/util/cast.js

View workflow job for this annotation

GitHub Actions / Test scratch-vm

Unnecessary 'else' after 'return'
// If it contains a decimal point, don't consider it an int.
return val.indexOf('.') < 0;
}
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/scratch-vm/test/unit/util_cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ test('isInt', t => {
t.equal(cast.isInt('0'), true);
t.equal(cast.isInt('1'), true);
t.equal(cast.isInt('0.0'), false);
t.equal(cast.isInt('0.1e10'), false);
t.equal(cast.isInt('0.1e10'), true);
t.equal(cast.isInt('3.14'), false);

// Boolean
Expand Down
Loading