INNER CODE UNIT · Python
short_url
Far-Se/tabame · plugins/api-client/main.py:200
def short_url(url, limit=60):
u = url or ""
return u if len(u) <= limit else u[: limit - 1] + "…"
def format_body_markdown(result):
body = result.get("body", "")
if not body:
return "_Empty response body_"
headers = result.get("headers") or {}
ctype = headers.get("Content-Type", "") or headers.get("content-type", "")
if "json" in ctype.lower():
try:
pretty = json.dumps(json.loads(body), indent=2, ensure_ascii=False)
return f"```json\n{pretty[:150000]}\n```"
except Exception:
pass
return f"```\n{body[:150000]}\n```"