Merge pull request #1002 from Flow-Launcher/fix_app_uri_logic

[Dev] Fix application URI logic when opening via WebSearch plugin
This commit is contained in:
Jeremy Wu 2022-03-02 10:19:30 +11:00 committed by GitHub
commit 813d900935
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 16 deletions

View file

@ -228,12 +228,26 @@ namespace Flow.Launcher.Plugin
public void OpenDirectory(string DirectoryPath, string FileName = null);
/// <summary>
/// Opens the url. The browser and mode used is based on what's configured in Flow's default browser settings.
/// Opens the URL with the given Uri object.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
/// </summary>
public void OpenUrl(Uri url, bool? inPrivate = null);
/// <summary>
/// Opens the URL with the given string.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
/// Non-C# plugins should use this method.
/// </summary>
public void OpenUrl(string url, bool? inPrivate = null);
/// <summary>
/// Opens the application URI.
/// Opens the application URI with the given Uri object, e.g. obsidian://search-query-example
/// </summary>
public void OpenAppUri(Uri appUri);
/// <summary>
/// Opens the application URI with the given string, e.g. obsidian://search-query-example
/// Non-C# plugins should use this method
/// </summary>
public void OpenAppUri(string appUri);
}

View file

@ -209,9 +209,8 @@ namespace Flow.Launcher
explorer.Start();
}
public void OpenUri(string url, bool? inPrivate = null, bool isAppUri = false)
private void OpenUri(Uri uri, bool? inPrivate = null)
{
var uri = new Uri(url);
if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
{
var browserInfo = _settingsVM.Settings.CustomBrowser;
@ -220,38 +219,43 @@ namespace Flow.Launcher
if (browserInfo.OpenInTab)
{
url.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
uri.AbsoluteUri.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
}
else
{
url.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
uri.AbsoluteUri.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
}
return;
}
if (isAppUri)
else
{
Process.Start(new ProcessStartInfo()
{
FileName = url,
FileName = uri.AbsoluteUri,
UseShellExecute = true
})?.Dispose();
return;
}
throw new InvalidOperationException("URI scheme not specified or supported ");
}
public void OpenUrl(string url, bool? inPrivate = null)
{
OpenUri(new Uri(url), inPrivate);
}
public void OpenUrl(Uri url, bool? inPrivate = null)
{
OpenUri(url, inPrivate);
}
public void OpenAppUri(string appUri)
{
OpenUri(appUri, isAppUri: true);
OpenUri(new Uri(appUri));
}
public void OpenAppUri(Uri appUri)
{
OpenUri(appUri);
}
public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;

View file

@ -49,9 +49,10 @@ namespace Flow.Launcher.Plugin.WebSearch
var title = keyword;
string subtitle = _context.API.GetTranslation("flowlauncher_plugin_websearch_search") + " " + searchSource.Title;
//Action Keyword match apear on top
// Action Keyword match apear on top
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreStandard : scoreStandard + 1;
// This populates the associated action keyword search entry
if (string.IsNullOrEmpty(keyword))
{
var result = new Result
@ -61,6 +62,7 @@ namespace Flow.Launcher.Plugin.WebSearch
IcoPath = searchSource.IconPath,
Score = score
};
results.Add(result);
}
else
@ -93,7 +95,6 @@ namespace Flow.Launcher.Plugin.WebSearch
if (token.IsCancellationRequested)
return null;
}
return results;