Skip to content

Commit

Permalink
In plaintext mode, end with a newline
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
egor-tensin authored and w4 committed Dec 24, 2023
1 parent 6e29e25 commit f3ef493
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ async fn submit_raw(
) -> 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);
Expand Down

0 comments on commit f3ef493

Please sign in to comment.