Prevent invalid urls from returning exceptions [MJ-277]

All tests pass.