From d62d7108787520187ad34fc8bcd95b462d4141fa Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 21 Sep 2022 12:01:58 -0400 Subject: [PATCH] Use URI class to detect web URL --- Flow.Launcher.Infrastructure/Image/ImageLoader.cs | 5 ++++- Flow.Launcher.Plugin/Result.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index 2349ab14d..a3e9de4b8 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -114,7 +114,10 @@ namespace Flow.Launcher.Infrastructure.Image { return new ImageResult(ImageCache[path], ImageType.Cache); } - if (path.StartsWith("http://") || path.StartsWith("https://")) + Uri uriResult; + bool IsUriScheme = Uri.TryCreate(path, UriKind.Absolute, out uriResult) + && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); + if (IsUriScheme) { // Download image from url using (WebClient client = new WebClient()) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 1fcfd8858..c784d60e0 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -130,8 +130,11 @@ namespace Flow.Launcher.Plugin get { return _pluginDirectory; } set { + Uri uriResult; + bool IsUriScheme = Uri.TryCreate(IcoPath, UriKind.Absolute, out uriResult) + && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); _pluginDirectory = value; - if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath) && !IcoPath.StartsWith("http://") && !IcoPath.StartsWith("https://")) + if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath) && !IsUriScheme) { IcoPath = Path.Combine(value, IcoPath); }