]>
zdv2.bktei.com Git - BK-2020-03.git/blob - unitproc/bkt-checkURL
   4     # Desc: Checks if string is a valid URL. 
   5     # Warning: Does not correctly handle multi-byte characters. 
   8     # Output: return code 0: string is a valid URL 
   9     #         return code 1: string is NOT a valid URL 
  11     # Ref/Attrib: https://stackoverflow.com/a/3184819 
  12     regex
='(https?|ftp|file|ssh|git)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' 
  14     if [[ $arg1 =~ 
$regex ]]; then 
  22 testString
="https://google.com/security.main.html" 
  23 if checkURL 
"$testString"; then echo "Is a valid URL:$testString"; else echo "Is NOT a valid URL:$testString"; fi; 
  24 testString
="ssh://username@host.xz/absolute/path/to/repo.git/" 
  25 if checkURL 
"$testString"; then echo "Is a valid URL:$testString"; else echo "Is NOT a valid URL:$testString"; fi;