Skip to content

Commit

Permalink
Update Address Null value Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Apr 30, 2024
1 parent bce387d commit 593eec7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/format/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ens-tools/format",
"version": "0.0.2",
"version": "0.0.3",
"description": "",
"main": "dist/index.js",
"type": "module",
Expand Down
2 changes: 2 additions & 0 deletions packages/format/src/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const AddressRegex = /^0x[\dA-Fa-f]{40}$/;
* @param address The address to format
*/
export const formatAddress = (address: string) => {
if (!address) return address;

if (address.match(AddressRegex) === null) return address;

return `${address.slice(0, 5)}...${address.slice(-4)}`;
Expand Down

0 comments on commit 593eec7

Please sign in to comment.