Fix bugs in shorten URL script