def normalize_fqdn(hostname) -> str:
    """Normalize full qualified domain name."""
    # Convert unicode hostname to punycode and
    # remove the port number from hostname
    hostname = hostname.encode("idna").decode().split(":")[0]

    # Strip exactly one dot from the right, if present
    if hostname[-1] == ".":
        hostname = hostname[:-1]

    return hostname