From 789ef5645d9b6e32b46eb58317d5b5733b0af674 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Fri, 19 Apr 2024 21:59:35 +0100 Subject: [PATCH] refactor: update web_pipe() to handle redirections --- quickget | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/quickget b/quickget index ab91588..96b276a 100755 --- a/quickget +++ b/quickget @@ -1445,7 +1445,13 @@ function check_hash() { } function web_pipe() { + # Check for URL redirections + # Output to nonexistent directory so the download fails fast local URL="${1}" + local REDIRECT_URL=$(curl --silent --location --fail "${URL}" --write-out %{url_effective} --output /var/cache/${RANDOM}/${RANDOM}) + if [ "${REDIRECT_URL}" != "${URL}" ]; then + URL="${REDIRECT_URL}" + fi curl --silent --location "${URL}" }