Fixing edge case where bad path can cause issues with url.parse