File tree Expand file tree Collapse file tree
packages/core/src/modules/credentials/formats/indy Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,7 +156,13 @@ export class IndyCredentialUtils {
156156 }
157157
158158 // If value is an int32 number string return as number string
159- if ( isString ( value ) && ! isEmpty ( value ) && ! isNaN ( Number ( value ) ) && this . isInt32 ( Number ( value ) ) ) {
159+ if (
160+ isString ( value ) &&
161+ ! isEmpty ( value ) &&
162+ ! isNaN ( Number ( value ) ) &&
163+ this . isNumeric ( value ) &&
164+ this . isInt32 ( Number ( value ) )
165+ ) {
160166 return Number ( value ) . toString ( )
161167 }
162168
@@ -194,4 +200,8 @@ export class IndyCredentialUtils {
194200 // Check if number is integer and in range of int32
195201 return Number . isInteger ( number ) && number >= minI32 && number <= maxI32
196202 }
203+
204+ private static isNumeric ( value : string ) {
205+ return / ^ - ? \d + $ / . test ( value )
206+ }
197207}
Original file line number Diff line number Diff line change @@ -74,6 +74,14 @@ const testEncodings: { [key: string]: { raw: string | number | boolean | null; e
7474 raw : '0.1' ,
7575 encoded : '9382477430624249591204401974786823110077201914483282671737639310288175260432' ,
7676 } ,
77+ 'str 1.0' : {
78+ raw : '1.0' ,
79+ encoded : '94532235908853478633102631881008651863941875830027892478278578250784387892726' ,
80+ } ,
81+ 'str 1' : {
82+ raw : '1' ,
83+ encoded : '1' ,
84+ } ,
7785 'leading zero number string' : {
7886 raw : '012345' ,
7987 encoded : '12345' ,
You can’t perform that action at this time.
0 commit comments