bti-shrink-urls - properly handle urls with :
authorBart Trojanowski <bart@jukie.net>
Mon, 23 Mar 2009 20:05:52 +0000 (16:05 -0400)
committerBart Trojanowski <bart@jukie.net>
Mon, 23 Mar 2009 20:06:47 +0000 (16:06 -0400)
bti-shrink-urls

index ee85b4c..aa9eb57 100755 (executable)
@@ -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