if (url.indexOf(query) !== -1) url = url.substring(0, url.indexOf(query) + query.length - 1);