new url cleaning function that preserves the hash fragment