mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
19 lines
323 B
JavaScript
19 lines
323 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import isIp from 'is-ip';
|
|
|
|
export default function formatHost(address, port) {
|
|
if (!address || !port) {
|
|
return undefined;
|
|
}
|
|
|
|
if (isIp.v6(address)) {
|
|
return `[${address}]:${port}`;
|
|
} else {
|
|
return `${address}:${port}`;
|
|
}
|
|
}
|