#!/bin/bash

## Copyright (C) 2022 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

#set -x
set -e

if [ "$1" = "" ]; then
   echo "$0: ERROR: No link given!" >&2
   exit 1
fi

curl_output=$(curl --silent --head "https://web.archive.org/save/$1")

location=$(echo "$curl_output" | grep '^location:')

link=$(echo "$location" | awk '{ print $2 }')

echo "$link"
