Skip to content

Commit dbac0f4

Browse files
author
Nhoya
committed
is_url function is a fucking badass
1 parent 2c46964 commit dbac0f4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

z0r

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ readonly YELLOW="\033[00;33m"
2222
readonly BOLD="\033[01m"
2323
readonly FINE="\033[0m"
2424

25-
ver='1.1'
25+
ver='1.2'
2626
regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*\.[-A-Za-z0-9\+&@#/%=~_|():?]+'
2727
is_z0r='http://z0r.it/[^ \n]'
2828
url=(http://$1)
2929
mode=-s
30-
dep=(curl awk xclip)
30+
dep=(curl awk xclip wget)
3131
apikey=4e4b657a91
3232
#upload function (long -> short)
3333
shr(){
@@ -69,10 +69,18 @@ echo $click
6969
#control over argument
7070
is_url(){
7171
if [[ $1 =~ $regex ]];then
72+
if wget --spider "$1" 2>/dev/null; then
7273
shr $1 $2
74+
else
75+
echo -e $RED"Page does not exist"$FINE
76+
fi
7377
else
7478
if [[ $url =~ $regex ]];then
75-
shr $1 $2
79+
if wget --spider "$1" 2>/dev/null; then
80+
shr $1 $2
81+
else
82+
echo -e $RED"Page does not exist"$FINE
83+
fi
7684
else
7785
echo -e $RED"Enter a valid url"$FINE
7886
fi

0 commit comments

Comments
 (0)