File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,8 @@ function getParseMode(value) {
6060 * @param {object } options Locale Options
6161 */
6262function parseWithLocale ( value , options ) {
63- const separator = getDecimalSeparator ( options ) ;
63+ const locale = options && options . locale ? options . locale : null ;
64+ const separator = getDecimalSeparator ( locale ) ;
6465 const regexNumberAndLocaleSeparator = new RegExp ( `[0-9${ separator } -]` , 'g' ) ;
6566 let numberAndLocaleSeparator = value . match ( regexNumberAndLocaleSeparator ) . join ( '' ) ;
6667 if ( separator === ',' ) {
Original file line number Diff line number Diff line change @@ -145,4 +145,17 @@ describe('parseAmount()', () => {
145145 it ( 'returns undefined when value is empty string' , ( ) => {
146146 expect ( parseAmount ( '' ) ) . to . equal ( undefined ) ;
147147 } ) ;
148+
149+ it ( 'parseAmount with locale set and length is more than four' , ( ) => {
150+ expect (
151+ parseAmount ( '6,000' , {
152+ locale : 'gb-GB' ,
153+ } ) ,
154+ ) . to . equal ( 6000 ) ;
155+ expect (
156+ parseAmount ( '6.000' , {
157+ locale : 'es-ES' ,
158+ } ) ,
159+ ) . to . equal ( 6000 ) ;
160+ } ) ;
148161} ) ;
You can’t perform that action at this time.
0 commit comments