Skip to content

Commit 1a373e1

Browse files
committed
prefer https over http setting
1 parent 5ae159d commit 1a373e1

File tree

7 files changed

+76
-4
lines changed

7 files changed

+76
-4
lines changed

Plugins/Flow.Launcher.Plugin.Url/Languages/de.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
<system:String x:Key="flowlauncher_plugin_url_plugin_set_tip">Bitte legen Sie Ihren Browser-Pfad fest:</system:String>
1515
<system:String x:Key="flowlauncher_plugin_url_plugin_choose">Wählen</system:String>
1616
<system:String x:Key="flowlauncher_plugin_url_plugin_filter">Anwendung (*.exe)|*.exe|Alle Dateien|*.*</system:String>
17+
18+
<system:String x:Key="flowlauncher_plugin_url_usehttps">https über http bevorzugen</system:String>
19+
1720
</ResourceDictionary>

Plugins/Flow.Launcher.Plugin.Url/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
<system:String x:Key="flowlauncher_plugin_url_plugin_set_tip">Please set your browser path:</system:String>
1616
<system:String x:Key="flowlauncher_plugin_url_plugin_choose">Choose</system:String>
1717
<system:String x:Key="flowlauncher_plugin_url_plugin_filter">Application(*.exe)|*.exe|All files|*.*</system:String>
18+
19+
<system:String x:Key="flowlauncher_plugin_url_usehttps">Prefer https over http</system:String>
1820
</ResourceDictionary>

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text.RegularExpressions;
4+
using System.Windows.Controls;
45

56
namespace Flow.Launcher.Plugin.Url
67
{
7-
public class Main : IPlugin, IPluginI18n
8+
public class Main : IPlugin, IPluginI18n, ISettingProvider
89
{
910
//based on https://gist.github.com/dperini/729294
1011
private const string urlPattern = "^" +
@@ -58,13 +59,13 @@ public List<Result> Query(Query query)
5859
Score = 8,
5960
Action = _ =>
6061
{
61-
if (!raw.ToLower().StartsWith("http"))
62+
if (!raw.ToLower().StartsWith(GetHttpPreference()))
6263
{
63-
raw = "http://" + raw;
64+
raw = GetHttpPreference() + "://" + raw;
6465
}
6566
try
6667
{
67-
Context.API.OpenUrl(raw);
68+
Context.API.OpenUrl(raw);
6869

6970
return true;
7071
}
@@ -80,6 +81,11 @@ public List<Result> Query(Query query)
8081
return new List<Result>(0);
8182
}
8283

84+
private string GetHttpPreference()
85+
{
86+
return _settings.AlwaysOpenWithHttps ? "https": "http";
87+
}
88+
8389
public bool IsURL(string raw)
8490
{
8591
raw = raw.ToLower();
@@ -113,5 +119,10 @@ public string GetTranslatedPluginDescription()
113119
{
114120
return Localize.flowlauncher_plugin_url_plugin_description();
115121
}
122+
123+
public Control CreateSettingPanel()
124+
{
125+
return new URLSettings(_settings);
126+
}
116127
}
117128
}

Plugins/Flow.Launcher.Plugin.Url/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ public class Settings
55
public string BrowserPath { get; set; }
66

77
public bool OpenInNewBrowserWindow { get; set; } = true;
8+
public bool AlwaysOpenWithHttps { get; set; } = false;
89
}
910
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
4+
namespace Flow.Launcher.Plugin.Url;
5+
6+
public class SettingsViewModel(Settings settings) : BaseModel
7+
{
8+
public Settings Settings { get; } = settings;
9+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<UserControl
2+
x:Class="Flow.Launcher.Plugin.Url.URLSettings"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:url="clr-namespace:Flow.Launcher.Plugin.Url"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Url"
9+
d:DataContext="{d:DesignInstance Type=viewModels:SettingsViewModel}"
10+
d:DesignHeight="450"
11+
d:DesignWidth="800"
12+
mc:Ignorable="d">
13+
14+
<Grid Margin="{StaticResource SettingPanelMargin}">
15+
<Grid.RowDefinitions>
16+
<RowDefinition Height="auto" />
17+
</Grid.RowDefinitions>
18+
<Grid.ColumnDefinitions>
19+
<ColumnDefinition Width="Auto" />
20+
</Grid.ColumnDefinitions>
21+
22+
<CheckBox
23+
Grid.Row="0"
24+
Grid.Column="0"
25+
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
26+
HorizontalAlignment="Left"
27+
VerticalAlignment="Center"
28+
Content="{DynamicResource flowlauncher_plugin_url_usehttps}"
29+
IsChecked="{Binding Settings.AlwaysOpenWithHttps, Mode=TwoWay}" />
30+
</Grid>
31+
</UserControl>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Windows.Controls;
2+
3+
namespace Flow.Launcher.Plugin.Url;
4+
5+
public partial class URLSettings : UserControl
6+
{
7+
private readonly SettingsViewModel _viewModel;
8+
9+
public URLSettings(Settings settings)
10+
{
11+
_viewModel = new SettingsViewModel(settings);
12+
DataContext = _viewModel;
13+
InitializeComponent();
14+
}
15+
}

0 commit comments

Comments
 (0)