X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/849106f7246e47bc077d7f3b8228cec717a8e63d..26f0533782d8c57fb95b8df4f55057edcbf17703:/unitproc/bktemp-checkURL diff --git a/unitproc/bktemp-checkURL b/unitproc/bktemp-checkURL deleted file mode 100644 index 6ae6ff0..0000000 --- a/unitproc/bktemp-checkURL +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -checkURL() { - # Desc: Checks if string is a valid URL. - # Warning: Does not correctly handle multi-byte characters. - # Version: 0.0.2 - # Input: arg1: string - # Output: return code 0: string is a valid URL - # return code 1: string is NOT a valid URL - # Depends: Bash 5.0.3 - # Ref/Attrib: https://stackoverflow.com/a/3184819 - regex='(https?|ftp|file|ssh|git)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' - arg1="$1"; - if [[ $arg1 =~ $regex ]]; then - return 0; - else - return 1; - fi; -} - -#==BEGIN sample code -testString="https://google.com/security.main.html" -if checkURL "$testString"; then echo "Is a valid URL:$testString"; else echo "Is NOT a valid URL:$testString"; fi; -testString="ssh://username@host.xz/absolute/path/to/repo.git/" -if checkURL "$testString"; then echo "Is a valid URL:$testString"; else echo "Is NOT a valid URL:$testString"; fi; -#==END sample code