mirror of
https://github.com/luxfhe/example-smart-wallet.git
synced 2026-10-30 18:13:16 +00:00
11 lines
331 B
TypeScript
11 lines
331 B
TypeScript
// Captures 0x + 4 characters, then the last 5 characters.
|
|
const truncateRegex = /^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{5})$/;
|
|
|
|
const truncateAddress = (address: string) => {
|
|
const match = address.match(truncateRegex);
|
|
if (!match) return address;
|
|
return `${match[1]}...${match[2]}`;
|
|
};
|
|
|
|
export default truncateAddress;
|