From 53918bf70d9551c0fd1188f03fa455439e18a8cc Mon Sep 17 00:00:00 2001 From: Omer Bektas Date: Sun, 16 Aug 2026 09:53:53 +0300 Subject: [PATCH] fix(vibenet): split acronym key labels --- app/vibenet/library/format.test.ts | 15 +++++++++++++++ app/vibenet/library/format.ts | 1 + 2 files changed, 16 insertions(+) create mode 100644 app/vibenet/library/format.test.ts diff --git a/app/vibenet/library/format.test.ts b/app/vibenet/library/format.test.ts new file mode 100644 index 0000000..6636bfd --- /dev/null +++ b/app/vibenet/library/format.test.ts @@ -0,0 +1,15 @@ +import { humanizeKey } from './format'; + +describe('humanizeKey', () => { + it('splits embedded acronym boundaries from the next word', () => { + expect(humanizeKey('myUSDCToken')).toBe('My USDC Token'); + expect(humanizeKey('someAPIKey')).toBe('Some API Key'); + expect(humanizeKey('lidoWSTETHVault')).toBe('Lido WSTETH Vault'); + }); + + it('preserves existing camelCase and separator behavior', () => { + expect(humanizeKey('usdvToken')).toBe('Usdv Token'); + expect(humanizeKey('l2OutputOracle')).toBe('L2 Output Oracle'); + expect(humanizeKey('base-usdc_bridge')).toBe('Base Usdc Bridge'); + }); +}); diff --git a/app/vibenet/library/format.ts b/app/vibenet/library/format.ts index 4f2550d..8679aa6 100644 --- a/app/vibenet/library/format.ts +++ b/app/vibenet/library/format.ts @@ -17,6 +17,7 @@ export function shortAddress(value: string, lead = 6, tail = 4): string { /** Fallback label for an unknown contract key, e.g. `usdvToken` -> `Usdv Token`. */ export function humanizeKey(key: string): string { const spaced = key + .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2') .replace(/([a-z0-9])([A-Z])/g, '$1 $2') .replace(/[_-]+/g, ' ') .trim();