ui: fix IPv6 formatting logic

This commit is contained in:
Matthew Penner 2023-01-12 11:28:11 -07:00
parent 42d8f2cb82
commit 76b67cb889
No known key found for this signature in database

View file

@ -8,7 +8,7 @@ function mbToBytes(megabytes: number): number {
} }
/** /**
* Given an amount of bytes, converts them into a human readable string format * Given an amount of bytes, converts them into a human-readable string format
* using "1024" as the divisor. * using "1024" as the divisor.
*/ */
function bytesToString(bytes: number, decimals = 2): string { function bytesToString(bytes: number, decimals = 2): string {
@ -28,7 +28,7 @@ function bytesToString(bytes: number, decimals = 2): string {
*/ */
function ip(value: string): string { function ip(value: string): string {
// noinspection RegExpSimplifiable // noinspection RegExpSimplifiable
return /([a-f0-9:]+:+)+[a-f0-9]+/.test(value) ? `[${value}]` : value; return /^([a-f0-9:]+:+)+[a-f0-9]+$/.test(value) ? `[${value}]` : value;
} }
export { ip, mbToBytes, bytesToString }; export { ip, mbToBytes, bytesToString };