Avoid shortening an already shortened url

This commit is contained in:
Jeremy Gardais 2020-03-11 18:40:37 +01:00
parent fcf9a26626
commit e6a1c8c62a
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 7 additions and 0 deletions

View File

@ -52,6 +52,13 @@ fi
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG Get URL: URL to be shortened: ${url_to_short}"
# ]]]
# Ensure the URL wasn't already shortened [[[
if printf -- '%s' "${url_to_short}" | grep -q -E -- "${null_service_url}"
then
printf "${c_redb}%b${c_reset}\n" "Error: The url to be shortened (${url_to_short}) already seems to comes from the 0x0 service (${null_service_url})."
exit 1
fi
# ]]]
# shorten URL
result=$(curl -sF"shorten=${url_to_short}" "${null_service_url}")