internal ApiUrls()

in src/Elastic.Clients.Elasticsearch/_Shared/Core/Request/ApiUrls.cs [27:52]


	internal ApiUrls(string[] routes)
	{
		if (routes == null || routes.Length == 0)
			throw new ArgumentException("urls is null or empty", nameof(routes));
		if (routes.Length == 1 && !routes[0].Contains("{"))
			_fixedUrl = routes[0];
		else
		{
			foreach (var route in routes)
			{
				var bracketsCount = route.Count(c => c.Equals('{'));
				if (Routes == null)
					Routes = new Dictionary<int, List<UrlLookup>>();
				if (Routes.ContainsKey(bracketsCount))
					Routes[bracketsCount].Add(new UrlLookup(route));
				else
					Routes.Add(bracketsCount, new List<UrlLookup> {new(route)});
			}
		}

		_errorMessageSuffix = string.Join(",", routes);

		// received multiple urls without brackets we resolve to first
		if (Routes == null)
			_fixedUrl = routes[0];
	}