Skip to content

Commit 96cf9fe

Browse files
committed
fix application URI logic when opening via WebSearch plugin
1 parent af313eb commit 96cf9fe

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,13 @@ public interface IPublicAPI
228228
public void OpenDirectory(string DirectoryPath, string FileName = null);
229229

230230
/// <summary>
231-
/// Opens the url. The browser and mode used is based on what's configured in Flow's default browser settings.
231+
/// Opens the URL. The browser and mode used is based on what's configured in Flow's default browser settings.
232+
/// Also supports application URIs e.g. obsidian://search-query-example
232233
/// </summary>
233234
public void OpenUrl(string url, bool? inPrivate = null);
234235

235236
/// <summary>
236-
/// Opens the application URI.
237+
/// Opens the application URI, e.g. obsidian://search-query-example
237238
/// </summary>
238239
public void OpenAppUri(string appUri);
239240
}

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public void OpenDirectory(string DirectoryPath, string FileName = null)
209209
explorer.Start();
210210
}
211211

212-
public void OpenUri(string url, bool? inPrivate = null, bool isAppUri = false)
212+
private void OpenUri(string url, bool? inPrivate = null)
213213
{
214214
var uri = new Uri(url);
215215
if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
@@ -230,18 +230,7 @@ public void OpenUri(string url, bool? inPrivate = null, bool isAppUri = false)
230230
return;
231231
}
232232

233-
if (isAppUri)
234-
{
235-
Process.Start(new ProcessStartInfo()
236-
{
237-
FileName = url,
238-
UseShellExecute = true
239-
})?.Dispose();
240-
241-
return;
242-
}
243-
244-
throw new InvalidOperationException("URI scheme not specified or supported ");
233+
OpenAppUri(url);
245234
}
246235

247236
public void OpenUrl(string url, bool? inPrivate = null)
@@ -251,7 +240,13 @@ public void OpenUrl(string url, bool? inPrivate = null)
251240

252241
public void OpenAppUri(string appUri)
253242
{
254-
OpenUri(appUri, isAppUri: true);
243+
Process.Start(new ProcessStartInfo()
244+
{
245+
FileName = appUri,
246+
UseShellExecute = true
247+
})?.Dispose();
248+
249+
return;
255250
}
256251

257252
public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;

Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
4949
var title = keyword;
5050
string subtitle = _context.API.GetTranslation("flowlauncher_plugin_websearch_search") + " " + searchSource.Title;
5151

52-
//Action Keyword match apear on top
52+
// Action Keyword match apear on top
5353
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreStandard : scoreStandard + 1;
5454

55+
// This populates the associated action keyword search entry
5556
if (string.IsNullOrEmpty(keyword))
5657
{
5758
var result = new Result
@@ -61,6 +62,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
6162
IcoPath = searchSource.IconPath,
6263
Score = score
6364
};
65+
6466
results.Add(result);
6567
}
6668
else
@@ -93,7 +95,6 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
9395

9496
if (token.IsCancellationRequested)
9597
return null;
96-
9798
}
9899

99100
return results;

0 commit comments

Comments
 (0)