Handle malformed URLs gracefully