mirror of
https://github.com/alexanderepstein/Bash-Snippets
synced 2018-11-08 02:59:35 +01:00
Fixing url shortner
Was setting newURL incorrectly
This commit is contained in:
parent
faa5af433e
commit
2bdf1248ff
1 changed files with 6 additions and 4 deletions
10
short/short
10
short/short
|
@ -110,8 +110,10 @@ usage()
|
||||||
{
|
{
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Short
|
Short
|
||||||
Description: Unmasks shortended urls.
|
Description: Shorten urls and unmask shortended urls.
|
||||||
Usage: short [shortURL] or short [flag]
|
Usage: short [flag] [URL] or short [flag]
|
||||||
|
-s Shorten the URL
|
||||||
|
-e Expand a shortened URL
|
||||||
-u Update Bash-Snippet Tools
|
-u Update Bash-Snippet Tools
|
||||||
-h Show the help
|
-h Show the help
|
||||||
-v Get the tool version
|
-v Get the tool version
|
||||||
|
@ -146,8 +148,8 @@ fi
|
||||||
|
|
||||||
shortenURL()
|
shortenURL()
|
||||||
{
|
{
|
||||||
newURL=$(echo $1 | grep -Eo "^[h]ttp[s]?://")
|
newURL=$1
|
||||||
if [[ $newURL == "" ]]; then newURL="http://"$1; fi
|
if [[ $(echo $1 | grep -Eo "^[h]ttp[s]?://") == "" ]]; then newURL="http://"$1; fi
|
||||||
response=$(curl -A curl -s -i -H "Content-Type: application/json" -X POST -d "{\"url\": \"$newURL\"}" http://ki.tc/ || exit 1)
|
response=$(curl -A curl -s -i -H "Content-Type: application/json" -X POST -d "{\"url\": \"$newURL\"}" http://ki.tc/ || exit 1)
|
||||||
returnedURL=$(echo $response | grep -Eo "http://ki.tc/[0-9a-zA-Z]*" | tail -n 1)
|
returnedURL=$(echo $response | grep -Eo "http://ki.tc/[0-9a-zA-Z]*" | tail -n 1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue