Added URL.replace in the try catch, otherwise ".replace" crash if the received URL is of the wrong format