github.com/hernad/nomad@v1.6.112/ui/app/utils/format-host.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import isIp from 'is-ip';
     7  
     8  export default function formatHost(address, port) {
     9    if (!address || !port) {
    10      return undefined;
    11    }
    12  
    13    if (isIp.v6(address)) {
    14      return `[${address}]:${port}`;
    15    } else {
    16      return `${address}:${port}`;
    17    }
    18  }