🏡 index : ~doyle/bin.git

author Egor Tensin <egor@tensin.name> 2023-12-24 15:55:08.0 +01:00:00
committer jordan <jordan@doyle.la> 2023-12-24 15:14:46.0 +00:00:00
commit
f3ef493ddfcaa0c4e00e32f3dc4e338f53a9a2ab [patch]
tree
e8fe0e8fe3916865c3ff11a5a0a6f9a293b742fa
parent
6e29e2578d4bc5c2eef3adc771771b7f3f66eba8
download
f3ef493ddfcaa0c4e00e32f3dc4e338f53a9a2ab.tar.gz

In plaintext mode, end with a newline

A curl call like

    curl -X PUT --data-binary @data.txt https://host/

outputs the paste URL without a newline a-la

    https://host/somepastenamewhich can mess up the terminal prompt. I

don't really see the downside of adding a newline. The workflow of

    url="$( curl -X PUT --data-binary @data.txt https://host/ )"
    curl "$url"

still works, since the shell strips the newline in command
substitutions.

Diff

 src/main.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 1a1a706..ffa608f 100644
--- a/src/main.rs
+++ a/src/main.rs
@@ -112,9 +112,9 @@
) -> Result<String, Error> {
    let id = generate_id();
    let uri = if let Some(Ok(host)) = host.0.as_ref().map(|v| std::str::from_utf8(v.as_bytes())) {
        format!("https://{host}/{id}")
        format!("https://{host}/{id}\n")
    } else {
        format!("/{id}")
        format!("/{id}\n")
    };

    store_paste(&store, id, data);