Check for relative URIs first

This commit is contained in:
ClemensFischer 2025-09-19 14:06:23 +02:00
parent cd40a627ce
commit f897ce3d36
2 changed files with 17 additions and 5 deletions

View file

@ -31,15 +31,23 @@ namespace MapControl
Stream xmlStream;
string defaultUrl = null;
if (uri.IsAbsoluteUri && (uri.Scheme == "http" || uri.Scheme == "https"))
if (!uri.IsAbsoluteUri)
{
xmlStream = File.OpenRead(uri.OriginalString);
}
else if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
{
defaultUrl = uri.OriginalString.Split('?')[0];
xmlStream = await ImageLoader.HttpClient.GetStreamAsync(uri);
}
else if (uri.IsFile)
{
xmlStream = File.OpenRead(uri.LocalPath);
}
else
{
xmlStream = File.OpenRead(uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString);
throw new ArgumentException($"Invalid Capabilities URI: {uri}");
}
using var stream = xmlStream;