diff --git a/snapaid.sh b/snapaid.sh index a29c436..b7da1bc 100755 --- a/snapaid.sh +++ b/snapaid.sh @@ -124,17 +124,21 @@ get_raw() { # get the location, it's a database lookup loc=$($WGET --max-redirect=0 --method=HEAD -S -o - -O - 'https://docs.freebsd.org/cgi/mid.cgi?'"$mid" 2>/dev/null | awk 'tolower($1) == "location:" { print $2; exit }') - # Some emails are sent to both -current and -snapshot, - # we can't handle them for now - # such as 20160529215940.GA11785@FreeBSD.org if [ x"$loc" = x"" ]; then - return 1 + # Some emails are sent to both -current and -snapshot, + # such as 20160529215940.GA11785@FreeBSD.org + # try w/ some magic sed + loc=$($WGET -O - 'https://docs.freebsd.org/cgi/mid.cgi?'"$mid" 2>/dev/null | + sed -Ee '/.*(getmsg.cgi?[^"]*).*/!d;s//\/cgi\/\1/' | head -1) fi - # if it's relative, add https + # if it's host relative, add https if [ x"$loc" != x"${loc#//}" ]; then # add https loc="https:$loc" + elif [ x"$loc" != x"${loc#/[^/]}" ]; then + # add https+host + loc="https://docs.freebsd.org$loc" fi # get the raw part