blob: 8a3b49e8cb18ceb7d3062f37fbd2ef2e8e803d61 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
|