fix url unwanted characters and trailing spaces