mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Check for relative URIs first
This commit is contained in:
parent
cd40a627ce
commit
f897ce3d36
|
|
@ -46,7 +46,11 @@ namespace MapControl
|
|||
|
||||
try
|
||||
{
|
||||
if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
|
||||
if (!uri.IsAbsoluteUri)
|
||||
{
|
||||
image = await LoadImageAsync(uri.OriginalString);
|
||||
}
|
||||
else if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
|
||||
{
|
||||
(var buffer, var _) = await GetHttpResponseAsync(uri, progress);
|
||||
|
||||
|
|
@ -55,9 +59,9 @@ namespace MapControl
|
|||
image = await LoadImageAsync(buffer);
|
||||
}
|
||||
}
|
||||
else if (uri.IsFile || !uri.IsAbsoluteUri)
|
||||
else if (uri.IsFile)
|
||||
{
|
||||
image = await LoadImageAsync(uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString);
|
||||
image = await LoadImageAsync(uri.LocalPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue