public static void UpdateHref(XRefMap map, Uri uri) { if (!string.IsNullOrEmpty(map.BaseUrl)) { if (!Uri.TryCreate(map.BaseUrl, UriKind.Absolute, out Uri baseUri)) { throw new InvalidDataException($"Xref map file (from {uri.AbsoluteUri}) has an invalid base url: {map.BaseUrl}."); } map.UpdateHref(baseUri); return; } if (uri.Scheme == "http" || uri.Scheme == "https") { map.UpdateHref(uri); return; } throw new InvalidDataException($"Xref map file (from {uri.AbsoluteUri}) missing base url."); }
public BasicXRefMapReader(XRefMap map) { Map = map ?? throw new ArgumentNullException(nameof(map)); if (map.HrefUpdated != true && map.BaseUrl != null) { if (!Uri.TryCreate(map.BaseUrl, UriKind.Absolute, out Uri baseUri)) { throw new InvalidDataException($"Xref map file has an invalid base url: {map.BaseUrl}."); } map.UpdateHref(baseUri); } }
public static void UpdateHref(XRefMap map, Uri uri) { if (!string.IsNullOrEmpty(map.BaseUrl)) { Uri baseUri; if (!Uri.TryCreate(map.BaseUrl, UriKind.Absolute, out baseUri)) { throw new InvalidDataException($"Xref map file (from {uri.AbsoluteUri}) has an invalid base url: {map.BaseUrl}."); } map.UpdateHref(baseUri); return; } if (uri.Scheme == "http" || uri.Scheme == "https") { map.UpdateHref(uri); return; } throw new InvalidDataException($"Xref map file (from {uri.AbsoluteUri}) missing base url."); }