commit b34045614f8d3fcdaaca85a2661bb98971efded0
parent 8d1ff8d883585968e7d85f54f2f2e60a413cfdf2
Author: Brian Mayer <bleemayer@gmail.com>
Date: Thu, 30 Jun 2022 17:15:59 -0300
Improved relative link navigation
Diffstat:
M | astro | | | 15 | ++++++++++----- |
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/astro b/astro
@@ -63,6 +63,13 @@ parseurl() {
url="$(echo "$1" | sed -e "s@$proto@@g")"
else
url="$1"
+ if [ "$oldhost" ]
+ then
+ case "$1" in
+ "/"*) url="$oldhost$1" ;;
+ *) url="$oldhost${oldpath%/*}/$1" ;;
+ esac
+ fi
fi
[ "$debug" ] && echo "url: $url" >&2 && sleep 2
@@ -71,12 +78,10 @@ parseurl() {
hostport="$(echo "$url" | sed -e "s/$user@//g" | cut -d/ -f1)"
host="$(echo "$hostport" | sed -e 's,:.*,,g')"
port="$(echo "$hostport" | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
- path="$(echo "$url" | grep / | cut -d/ -f2-)"
+ path="$(echo "${url#/*}" | sed "s@/\?$hostport@@")"
- [ "$oldhost" ] && [ ! "$path" ] && path="$host" && host="$oldhost"
- [ "$oldhost" ] && [ ! "$host" ] && host="$oldhost"
- [ "$debug" ] && echo "Parsed: proto: ${proto:-gemini} host: $host port: ${port:-1965} path: ${path#/}" >&2 && sleep 2
- echo "${proto:-gemini}" "$host" "${port:-1965}" "${path#/}" "$rest"
+ [ "$debug" ] && echo "Parsed: proto: ${proto:-gemini} host: $host port: ${port:-1965} path: ${path#/*}" >&2 && sleep 2
+ echo "${proto:-gemini}" "$host" "${port:-1965}" "${path#/*}" "$rest"
return 0
}