Skip to content

Commit 9109653

Browse files
committed
Fix grep to be case-insensitive for redirects
1 parent e968bc7 commit 9109653

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fetchurls.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
VERSION="v3.2.5"
3+
VERSION="v3.3.0"
44

55
# Set Defaults
66
WGET_INSTALLED=0
@@ -423,13 +423,13 @@ elif [ -z "$USER_DOMAIN" ] && [ "$RUN_NONINTERACTIVE" -eq 1 ]; then
423423
fi
424424

425425
USER_DOMAIN="${USER_DOMAIN%/}"
426-
DISPLAY_DOMAIN="$(echo ${USER_DOMAIN} | grep -oP "^http(s)?://(www\.)?\K.*")"
427-
GENERATED_FILENAME="$(echo ${USER_DOMAIN} | grep -oP "^http(s)?://(www\.)?\K.*" | tr "." "-")"
426+
DISPLAY_DOMAIN="$(echo ${USER_DOMAIN} | grep -ioP "^http(s)?://(www\.)?\K.*")"
427+
GENERATED_FILENAME="$(echo ${USER_DOMAIN} | grep -ioP "^http(s)?://(www\.)?\K.*" | tr "." "-")"
428428
# Remove non-alpha-numeric characters (other than dash)
429429
GENERATED_FILENAME="$(echo "$GENERATED_FILENAME" | sed 's/[^[:alnum:]-]/-/g')"
430430

431431
# Check if URL is valid and returns 200 status
432-
URL_STATUS=$(wget --spider -q --server-response $USER_DOMAIN 2>&1 | grep --max-count=1 "HTTP/" | awk '{print $2}')
432+
URL_STATUS=$(wget --spider -q --server-response $USER_DOMAIN 2>&1 | grep --max-count=1 --ignore-case "HTTP/" | awk '{print $2}')
433433

434434
if [ -z "$URL_STATUS" ]; then
435435
echo "${COLOR_RESET}"
@@ -439,7 +439,7 @@ if [ -z "$URL_STATUS" ]; then
439439
# If response is 3xx, follow redirect
440440
elif [ "$URL_STATUS" -ge 300 ] && [ "$URL_STATUS" -le 399 ]; then
441441
# Get redirect URL
442-
FORWARDED_URI=$(wget --spider -q --server-response $USER_DOMAIN 2>&1 | grep --max-count=1 "Location" | awk '{print $2}')
442+
FORWARDED_URI=$(wget --spider -q --server-response $USER_DOMAIN 2>&1 | grep --max-count=1 --ignore-case "Location" | awk '{print $2}')
443443
echo "${COLOR_RESET}"
444444

445445
if [ "$URL_STATUS" -eq 301 ]; then

0 commit comments

Comments
 (0)