[fix] be defensive and ensure location is in headers before running url.parse()