URL may contain special characters like &, coma, etc but some special characters will not support on XML.
the below code can be used for replacing special characters in the URL.
var value = "url" // type url here
var value1; // varibale to store the new url
value1 = value.replace(/&/g, "&")
value1 = value1.replace(/</g, "<")
value1 = value1.replace(/>/g, ">")
value1 = value1.replace(/"/g, """)
value1 = value1.replace(/'/g, "'");
return value1