From: Bart Trojanowski Date: Mon, 23 Mar 2009 20:05:52 +0000 (-0400) Subject: bti-shrink-urls - properly handle urls with : X-Git-Url: https://git.toastfreeware.priv.at/gregoa/bti.git/commitdiff_plain/f7d42cbadbf5c7b2fbdfd75586afbc87e2976519 bti-shrink-urls - properly handle urls with : --- diff --git a/bti-shrink-urls b/bti-shrink-urls index ee85b4c..aa9eb57 100755 --- a/bti-shrink-urls +++ b/bti-shrink-urls @@ -42,7 +42,7 @@ done function convert_url() { local url=$1 test -n "$url" || return 1 - test "${url%:*}" = 'http' || return 1 + test "${url%%:*}" = 'http' || return 1 local urllen="${#url}" @@ -73,7 +73,7 @@ function convert_url() { local submit="http://2tu.us/?save=y&url=$url" local res=$(wget -q -O - "$submit" | awk -F"'" '/Your tight URL is:/ { print $2 }') - if test "${res%:*}" = 'http' -a "${#res}" -lt "$urllen" ; then + if test "${res%%:*}" = 'http' -a "${#res}" -lt "$urllen" ; then echo $res return 0 fi