mirror of
https://github.com/benjaminion/upgrading-ethereum-book.git
synced 2026-01-09 14:38:08 -05:00
Add url checker
This commit is contained in:
24
bin/util/urlcheck.sh
Executable file
24
bin/util/urlcheck.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check availability of external markdown links in the supplied document.
|
||||
|
||||
# Github severely rate limits unless you use your access creds.
|
||||
github_secret=$(cat ../priv/github.txt)
|
||||
|
||||
for x in $(grep -Pho '\(\Khttp[^)]+' $1 | sed 's/#.*$//g' | sort -u)
|
||||
do
|
||||
echo $x;
|
||||
|
||||
# Include credentials for github.com
|
||||
[[ "$x" =~ .*github.com* ]] && creds="-u $github_secret" || creds=""
|
||||
|
||||
# beaconcha.in doesn't like HEAD requests
|
||||
[[ "$x" =~ .*beaconcha.in* ]] && head="" || head="--head"
|
||||
|
||||
res=$(curl $creds -Lo /dev/null --silent $head --write-out '%{http_code}\n' $x)
|
||||
|
||||
if [ "200" -ne "$res" ]
|
||||
then
|
||||
echo "*** $res ***"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user