Skip to content

Commit 8e6a410

Browse files
committed
Use url host
1 parent bdb3616 commit 8e6a410

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Flow.Launcher/Helper/PluginInstallationHelper.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,16 @@ private static bool InstallSourceKnown(string url)
268268
return false;
269269

270270
var author = pieces[3];
271+
var acceptedHost = "github.com";
271272
var acceptedSource = "https://github.com";
272273
var constructedUrlPart = string.Format("{0}/{1}/", acceptedSource, author);
273274

274-
return url.StartsWith(acceptedSource) &&
275-
App.API.GetAllPlugins().Any(x =>
276-
!string.IsNullOrEmpty(x.Metadata.Website) &&
277-
x.Metadata.Website.StartsWith(constructedUrlPart)
278-
);
275+
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri) || uri.Host != acceptedHost)
276+
return false;
277+
278+
return App.API.GetAllPlugins().Any(x =>
279+
!string.IsNullOrEmpty(x.Metadata.Website) &&
280+
x.Metadata.Website.StartsWith(constructedUrlPart)
281+
);
279282
}
280283
}

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,14 +626,17 @@ private bool InstallSourceKnown(string url)
626626
return false;
627627

628628
var author = pieces[3];
629+
var acceptedHost = "github.com";
629630
var acceptedSource = "https://github.com";
630631
var constructedUrlPart = string.Format("{0}/{1}/", acceptedSource, author);
631632

632-
return url.StartsWith(acceptedSource) &&
633-
Context.API.GetAllPlugins().Any(x =>
634-
!string.IsNullOrEmpty(x.Metadata.Website) &&
635-
x.Metadata.Website.StartsWith(constructedUrlPart)
636-
);
633+
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri) || uri.Host != acceptedHost)
634+
return false;
635+
636+
return Context.API.GetAllPlugins().Any(x =>
637+
!string.IsNullOrEmpty(x.Metadata.Website) &&
638+
x.Metadata.Website.StartsWith(constructedUrlPart)
639+
);
637640
}
638641

639642
internal async ValueTask<List<Result>> RequestInstallOrUpdateAsync(string search, CancellationToken token,

0 commit comments

Comments
 (0)