make sure url.query exists

Sometimes `url.query` is null, this prevents from throwing error.