diff --git a/src/lib/formatters/formatters.ts b/src/lib/formatters/formatters.ts index ec65042..5ff5c2a 100644 --- a/src/lib/formatters/formatters.ts +++ b/src/lib/formatters/formatters.ts @@ -27,3 +27,10 @@ export function addressFormatter(val: string, shortify?: boolean) { const address = getAddress(val); return shortify ? `${address.substring(0, 6)}...${address?.slice(-4)}` : address; } + +export function urlFormatter(val: string) { + val = val.trim().toLowerCase(); + return val.startsWith('http://') || val.startsWith('https://') + ? val + : val.replace(/^(?!(?:\w+?:)?\/\/)/, 'https://'); +} diff --git a/src/pages/WorkersPage/WorkerStatistics.tsx b/src/pages/WorkersPage/WorkerStatistics.tsx index de32e1f..a8759d6 100644 --- a/src/pages/WorkersPage/WorkerStatistics.tsx +++ b/src/pages/WorkersPage/WorkerStatistics.tsx @@ -5,6 +5,7 @@ import { bytesFormatter, numberWithSpacesFormatter, percentFormatter, + urlFormatter, } from '@lib/formatters/formatters.ts'; import { Box, Divider, Stack, styled } from '@mui/material'; @@ -78,7 +79,13 @@ export const WorkerStatistics = ({ worker }: { worker: BlockchainApiFullWorker } Website - {worker.website ? {worker.website} : '-'} + {worker.website ? ( + + {urlFormatter(worker.website)} + + ) : ( + '-' + )}