Maybe each of these could be split into separate descriptive methods and put together to achieve the sanitized URL? String sanitation is a notoriously ugly process and maybe breaking things out into separate private methods could aid in elucidating what is happening.