Skip to content

Commit 17fee1c

Browse files
committed
Script to validate URLs
1 parent 900b42c commit 17fee1c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

scripts/check_urls.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -euo pipefail
9+
10+
green='\e[1;32m'; red='\e[1;31m'; cyan='\e[1;36m'; yellow='\e[1;33m'; reset='\e[0m'
11+
last= rc=0
12+
while IFS=: read -r f u; do
13+
if [ "$f" != "$last" ]; then
14+
[ -n "$last" ] && echo
15+
printf '%s:\n' "$f"
16+
last=$f
17+
fi
18+
if curl --fail -s -m10 -o /dev/null "$u"; then
19+
printf " ${green}[OK]${reset} ${cyan}%s${reset}\n" "$u"
20+
else
21+
printf "${red}[FAIL]${reset} ${yellow}%s${reset}\n" "$u"
22+
rc=1
23+
fi
24+
done < <(
25+
git --no-pager grep --no-color -I -o -E 'https?://[^[:space:]<>\")\{]+' \
26+
-- '*' \
27+
':(exclude).*' ':(exclude)**/.*' ':(exclude)**/*.lock' ':(exclude)**/third-party/**' \
28+
| sed 's/[."\’]$//'
29+
)
30+
exit $rc

0 commit comments

Comments
 (0)