improved sanitizeUrl