From e6a1c8c62a13fb08fe28c804528ffb8421673af3 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 11 Mar 2020 18:40:37 +0100 Subject: [PATCH] Avoid shortening an already shortened url --- url.shortme.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/url.shortme.sh b/url.shortme.sh index da30115..df501b1 100755 --- a/url.shortme.sh +++ b/url.shortme.sh @@ -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}")