The naive root + path might cause cases of double slashes e.g. http://path//relative-path.

This indeed happened with the out of the box Google cloud endpoints GA discovery documents.
Switch to url.resolve() to solve those cases.