Use url.parse instead of manually checking baseURL.

Closes #2085.