Properly merging URLs and removing dot segments based on RFC 3986 section 5.4. Closes #288 and #289.