refactor: update web_pipe() to handle redirections

This commit is contained in:
Martin Wimpress 2024-04-19 21:59:35 +01:00 committed by Martin Wimpress
parent 6662ab1740
commit 789ef5645d
1 changed files with 6 additions and 0 deletions

View File

@ -1445,7 +1445,13 @@ function check_hash() {
} }
function web_pipe() { function web_pipe() {
# Check for URL redirections
# Output to nonexistent directory so the download fails fast
local URL="${1}" 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}" curl --silent --location "${URL}"
} }