By using this code remove the last element from the Url link.
url.substring(0, url.lastIndexOf("https://stackoverflow.com/"));
By using this code remove the last element from the Url link.
url.substring(0, url.lastIndexOf("https://stackoverflow.com/"));