INNER CODE UNIT · Python

_serialize_domain

atenreiro/opensquat · opensquat/cli.py:29

def _serialize_domain(d):
    """
    Serialize a LookalikeDomain into a JSON-friendly dict.

    Optional fields (tld, date, unicode) are omitted when they're None so
    the output stays compact. `idn` is always emitted, even when False,
    because the boolean presence is informative: it tells consumers the
    tool checked and the domain is not a homograph (vs. not having the
    information at all, which is what community/feed modes look like).
    """
    out = {"domain": d.domain}
    if d.tld is not None:
        out["tld"] = d.tld
    if d.date is not None:
        out["date"] = d.date
    out["idn"] = d.idn
    if d.idn and d.unicode is not None:
        out["unicode"] = d.unicode

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…