Ignore:
Timestamp:
May 22, 2023, 12:22:55 AM (18 months ago)
Author:
iritscen
Message:

ValExtLinks: Added --only-200-ok argument.

Location:
Validate External Links
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Validate External Links/validate_external_links.command

    r1182 r1184  
    3535
    3636# Normal run with no upload
    37 #bash "$VALEXTLINKS" --links "$LINKS_ONLINE" --exceptions "$EXCEPT_ONLINE" --output "$REPORT_DIR" --suggest-snapshots-ng --timeout 10 --show-https-upgrades --show-added-slashes
     37#bash "$VALEXTLINKS" --links "$LINKS_ONLINE" --exceptions "$EXCEPT_ONLINE" --output "$REPORT_DIR" --suggest-snapshots-ng --timeout 10 --show-https-upgrades --show-added-slashes --show-yt-redirects
    3838
    3939# Normal run
  • Validate External Links/validate_external_links.sh

    r1183 r1184  
    3434OUTPUT_DIR=""           # place reports and all other output in a folder inside this existing folder
    3535RECORD_OK_LINKS=0      # record response code to the log even when it's a value in OK_CODES
     36ONLY_200_OK=0          # only treat code 200 as "OK" and not any other code in OK_CODES
    3637SHOW_SLASH=0           # record issue when a slash is added to the end of a URL
    3738SHOW_HTTPS=0           # record issue when "http" is upgraded to "https"
     
    6869
    6970# These arrays tell the script which suffixes at the ends of URLs represent files and which are pages.
    70 # This determines whether the script tries to take a screenshot of the URL or just gets its HTTP code.
     71# This determines whether the script tries to take a screenshot of the URL (when screenshots are
     72# requested).
    7173declare -a HTTP_FILES=(3ds 7z avi BINA blend bsl cpp csv dae dll dmg doc east exe fbx first63 flv gamedata gif jpg last32 log m4a mhm mov mp3 mp4 oni ONWC pdf png psd py rar tga TRMA txt vbs wav wmv xaf xcf xlsx xml zip)
    7274declare -a HTTP_TLDS_AND_PAGES=(abstract action ars asp aspx cfm cgi com css de do full htm html it js jsp net org pgi php php3 phtml pl ru shtml stm uk x)
     
    135137       validate_external_links.sh --help
    136138       validate_external_links.sh --links URL --output DIR [--exceptions URL]
    137           [--record-ok-links] [--show-added-slashes] [--show-https-upgrades]
    138           [--show-yt-redirects] [--suggest-snapshots] [--check-archive-links]
    139           [--take-screenshots FILE] [--timeout NUM] [--start-url NUM]
    140           [--end-url NUM] [--upload FILE]
     139          [--record-ok-links] [--only-200-ok] [--show-added-slashes]
     140          [--show-https-upgrades] [--show-yt-redirects] [--suggest-snapshots]
     141          [--check-archive-links] [--take-screenshots FILE] [--timeout NUM]
     142          [--start-url NUM] [--end-url NUM] [--upload FILE]
    141143
    142144DESCRIPTION
     
    173175       --record-ok-links       Log a link in the report even if its response
    174176                               code is "OK".
     177       --only-200-ok           Only treat response code 200 as "OK". Normally
     178                               several additional codes are treated as "OK" (see
     179                               the array OK_CODES in script) because they are
     180                               typically not an indicator of a bad link.
    175181       --show-added-slashes    Report on redirects that simply add a '/' to the
    176182                               end of the URL.
     
    226232      --output )               OUTPUT_DIR="$2";                    shift 2;;
    227233      --record-ok-links )      RECORD_OK_LINKS=1;                  shift;;
     234      --only-200-ok )          ONLY_200_OK=1;                      shift;;
    228235      --show-added-slashes )   SHOW_SLASH=1;                       shift;;
    229236      --show-https-upgrades )  SHOW_HTTPS=1;                       shift;;
     
    704711valPrint ctrhn "Show OK links: "
    705712if [ $RECORD_OK_LINKS -eq 1 ]; then valPrint ctrh "Yes"; else valPrint ctrh "No"; fi
     713
     714valPrint ctrhn "Treat these response codes as OK: "
     715if [ $ONLY_200_OK -eq 1 ]; then valPrint ctrh "200"; else valPrint ctrh "${OK_CODES[*]}"; fi
    706716
    707717valPrint ctrhn "Take screenshots: "
     
    10071017   if [ $STATUS == "??" ]; then
    10081018      for CODE in "${OK_CODES[@]}"; do
     1019         if [ $ONLY_200_OK -eq 1 ] && [ $CODE -ne 200 ]; then
     1020            continue
     1021         fi
     1022     
    10091023         if [[ $CODE == $CURL_CODE ]]; then
    10101024            STATUS="OK"
     
    11431157         fi
    11441158      done
     1159      # Also check it against the "OK" codes besides 200 if the --only-200-ok argument was received
     1160      if [ $ONLY_200_OK -eq 1 ]; then
     1161         for CODE in "${OK_CODES[@]}"; do
     1162            if [ $CODE -eq 200 ]; then
     1163               continue
     1164            fi
     1165            if [[ $CODE == $CURL_CODE ]]; then
     1166               STATUS="NG"
     1167               let NG_LINKS+=1
     1168               break
     1169            fi
     1170         done
     1171      fi
    11451172   fi
    11461173
Note: See TracChangeset for help on using the changeset viewer.