I’ve got two Urls. A server and a relative url that I would like to combine. The problem is that part of the url’s may well overlap. I’ve done this using some horrible string manipulation but would like to put this out there and see if there is a nice and clean way of doing it.
string siteUrl = "http://seed-dev6/sites/irs";
string formUrl = "/sites/irs/Forms/testform.xsn";
I would split the URLs based on their path separator
/, merge the lists without duplicates while preserving order, and then concatenate them into a single URL string.This avoids the crazy string manipulation and search you need to do. THe only complicating factor is making the code capable of dealing with different case (upper vs. lower), and web escape code %20, etc.