Skip to content

Commit 6afc6ec

Browse files
willfeldmandehesa
authored andcommitted
Updated functionality of is-it-up.sh
Updated script to work with urls with http://, https://, and www. without giving an error.
1 parent aedc28f commit 6afc6ec

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

commands/developer-utils/is-it-up.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,19 @@ if ! command -v jq &> /dev/null; then
2323
exit 1;
2424
fi
2525

26-
status_code=$(curl --silent "https://isitup.org/$1.json" | jq '.status_code')
26+
# Get the url from the user input
27+
url=$1
28+
29+
# Remove any protocol prefix (http:// or https://)
30+
url=${url#*://}
31+
32+
# Remove any www. prefix
33+
url=${url#www.}
34+
35+
# Remove any trailing slash
36+
url=${url%/}
37+
38+
status_code=$(curl --silent "https://isitup.org/${url}.json" | jq '.status_code')
2739

2840
# Sample output:
2941
#

0 commit comments

Comments
 (0)