Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Muhammad Altabba <[email protected]>
  • Loading branch information
mpetrunic and Muhammad-Altabba authored Nov 17, 2023
1 parent a6af301 commit ec7d47f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/web3-validator/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,13 @@ const charCodeMap = {

export function hexToUint8Array(hex: string): Uint8Array {
let offset = 0;
if (hex.toLowerCase().startsWith('0x')) {
if (hex[0] === '0' && (hex[1] === 'x' || hex[1] === 'X')) {
offset = 2;
}
if (hex.length % 2 !== 0) {
throw new InvalidBytesError(`hex string has odd length: ${hex}`);
}
const length = Math.ceil((hex.length-offset) / 2);
const length = (hex.length - offset) / 2;
const bytes = new Uint8Array(length);
for (let index = 0, j = offset; index < length; index+=1) {
// eslint-disable-next-line no-plusplus
Expand Down

0 comments on commit ec7d47f

Please sign in to comment.