diff options
author | epoch <epoch@hacking.allowed.org> | 2020-11-15 19:11:16 -0600 |
---|---|---|
committer | epoch <epoch@hacking.allowed.org> | 2020-11-15 19:11:16 -0600 |
commit | 4f9509b7fe0e345f5d8fa7540adba45b1a363f81 (patch) | |
tree | 1c914753fc1f41debbe4ebc666dc521484fdd5f1 /unshorten.sh | |
parent | 29ec2d6b6dccab65335be8bf203f0f139d876f97 (diff) | |
download | uritools-4f9509b7fe0e345f5d8fa7540adba45b1a363f81.tar.gz uritools-4f9509b7fe0e345f5d8fa7540adba45b1a363f81.zip |
added unshorten.sh which attempts to unshorten shortened URLs. and data_handler... no comment.
Diffstat (limited to 'unshorten.sh')
-rwxr-xr-x | unshorten.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/unshorten.sh b/unshorten.sh new file mode 100755 index 0000000..8a3b49e --- /dev/null +++ b/unshorten.sh @@ -0,0 +1,18 @@ +#!/bin/sh +uri="$1" +path="$(printf '%s\n' "$uri" | uricut -p)" +scheme="$(printf '%s\n' "$uri" | uricut -s)" +domain="$(printf '%s\n' "$uri" | uricut -d)" +port="$(printf '%s\n' "$uri" | uricut -P)" + +case "$scheme" in + http*) + curl -Lsi "$1" | grep -i ^Location: | head -n1 | tr -s ' ' | tr -d '\r' | cut '-d ' -f2- | sed 's|^/|'"$scheme"'://'"$domain"'/|g' + ;; + gemini) + gemini-get "$1" | head -n1 | sed 's/^3[0-9] //g' + ;; + *) + printf "dunno how to handle this type of URI\n" + ;; +esac |