Test if a string is a HTTP, HTTPS, FTP or FILE URL.
is-url
tests if given string match with a URL validation regex restricted
to web protocols (i.e. HTTP, HTTPS, FTP and FILE).
Test if given string match with a URL validation regex restricted to web protocols (i.e. HTTP, HTTPS and FTP).
source "${BASH_SOURCE[0]%/*}/libs/biapy-bashlings/src/is-url.bash"
if is-url "${url}"; then
wget "${url}"
else
echo "Error: '${url}' is not a valid url." >&2
exit 1
fi
- $1 (string): A string that may be a valid URL.
- 0: If string is a valid HTTPS, HTTP, FTP or FILE URL.
- 1: If argument is missing or more than one argument given.
- 1: If string is not a URL or URL with an invalid protocol.
- Error if the argument is missing or more than one argument is given.