File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -425,7 +425,9 @@ function parse (args, opts) {
425
425
426
426
function maybeCoerceNumber ( key , value ) {
427
427
if ( ! checkAllAliases ( key , flags . strings ) && ! checkAllAliases ( key , flags . coercions ) ) {
428
- const shouldCoerceNumber = isNumber ( value ) && configuration [ 'parse-numbers' ] && ( Number . isSafeInteger ( parseInt ( value ) ) )
428
+ const shouldCoerceNumber = isNumber ( value ) && configuration [ 'parse-numbers' ] && (
429
+ Number . isSafeInteger ( Math . floor ( value ) )
430
+ )
429
431
if ( shouldCoerceNumber || ( ! isUndefined ( value ) && checkAllAliases ( key , flags . numbers ) ) ) value = Number ( value )
430
432
}
431
433
return value
Original file line number Diff line number Diff line change @@ -2479,6 +2479,11 @@ describe('yargs-parser', function () {
2479
2479
argv . foo . should . equal ( '93940495950949399948393' )
2480
2480
} )
2481
2481
2482
+ it ( 'does not magically convert scientific notation larger than Number.MAX_SAFE_INTEGER' , ( ) => {
2483
+ const argv = parser ( [ '--foo' , '33e99999' ] )
2484
+ argv . foo . should . equal ( '33e99999' )
2485
+ } )
2486
+
2482
2487
it ( 'converts numeric options larger than Number.MAX_SAFE_INTEGER to number' , ( ) => {
2483
2488
const argv = parser ( [ '--foo' , '93940495950949399948393' ] , {
2484
2489
number : [ 'foo' ]
You can’t perform that action at this time.
0 commit comments