owncast/web/pages/utils/format.ts
2020-10-26 16:13:25 -07:00

14 lines
370 B
TypeScript

export function formatIPAddress(ipAddress: string): string {
const ipAddressComponents = ipAddress.split(':')
// Wipe out the port component
ipAddressComponents[ipAddressComponents.length - 1] = '';
let ip = ipAddressComponents.join(':')
ip = ip.slice(0, ip.length - 1)
if (ip === '[::1]' || ip === '127.0.0.1') {
return "Localhost"
}
return ip;
}