xh icon indicating copy to clipboard operation
xh copied to clipboard

JSON pretty printing inserts extra newline

Open eproxus opened this issue 1 year ago • 3 comments

Compare:

$ xh get https://jsonplaceholder.typicode.com/todos/1
HTTP/2.0 200 OK
...headers...

{
    "userId": 1,
    "id": 1,
    "title": "delectus aut autem",
    "completed": false
}


$

With:

$ xh get google.com
HTTP/1.1 301 Moved Permanently
...headers...

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

$

(Maybe the last newline should be stripped in the HTML case too?)

eproxus avatar Jan 18 '24 11:01 eproxus

This is intentional. see #109

zuisong avatar Apr 09 '24 05:04 zuisong

Is it really needed at the end of the output? It feels like it just wastes space in the terminal... 🙂 (I can see the need between bodies/chunks, but not at the end of the output).

eproxus avatar Apr 09 '24 09:04 eproxus

Related: https://github.com/httpie/cli/issues/1547

blyxxyz avatar Apr 09 '24 20:04 blyxxyz