pure bash implementation of fix_url()