File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -425,7 +425,9 @@ function parse (args, opts) {
425425
426426 function maybeCoerceNumber ( key , value ) {
427427 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+ )
429431 if ( shouldCoerceNumber || ( ! isUndefined ( value ) && checkAllAliases ( key , flags . numbers ) ) ) value = Number ( value )
430432 }
431433 return value
Original file line number Diff line number Diff line change @@ -2479,6 +2479,11 @@ describe('yargs-parser', function () {
24792479 argv . foo . should . equal ( '93940495950949399948393' )
24802480 } )
24812481
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+
24822487 it ( 'converts numeric options larger than Number.MAX_SAFE_INTEGER to number' , ( ) => {
24832488 const argv = parser ( [ '--foo' , '93940495950949399948393' ] , {
24842489 number : [ 'foo' ]
You can’t perform that action at this time.
0 commit comments