Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Support for Microsoft Edge. #4

Merged
merged 2 commits into from
Oct 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DanTup.BrowserSelector/BrowserSelector.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; Default browser is first in list
; Micrsoft Edge is a UWP app and requires no path
[browsers]
chrome = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
ff = C:\Program Files (x86)\Mozilla Firefox\firefox.exe
edge =
ie = iexplore.exe

; Url preferences.
Expand Down
15 changes: 12 additions & 3 deletions DanTup.BrowserSelector/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Security.Principal;
Expand All @@ -9,7 +10,12 @@ namespace DanTup.BrowserSelector
{
class Program
{
static void Main(string[] args)
static readonly Dictionary<string, string> SpecialCommands = new Dictionary<string, string>
{
{"edge", "microsoft-edge:{0}"}
};

static void Main(string[] args)
{
if (args == null || args.Length != 1 || !HandleArg(args[0]))
ShowHelpInfo();
Expand Down Expand Up @@ -85,8 +91,11 @@ static void LaunchBrowser(string url)

if (Regex.IsMatch(domain, pattern))
{
Process.Start(preference.Browser.Location, url);
return;
if (SpecialCommands.ContainsKey(preference.Browser.Name))
Process.Start(string.Format(SpecialCommands[preference.Browser.Name], url));
else
Process.Start(preference.Browser.Location, url);
return;
}
}

Expand Down
4 changes: 2 additions & 2 deletions DanTup.BrowserSelector/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
[assembly: AssemblyTitle("DanTup.BrowserSelector")]
[assembly: AssemblyProduct("DanTup.BrowserSelector")]
[assembly: AssemblyCopyright("Copyright © Danny Tuppeny 2015")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ Small utility to launch a different browser depending on the domain of the url b
Config is a poor mans INI file:

; Default browser is first in list
; Micrsoft Edge is a UWP app and requires no path
[browsers]
chrome = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
ff = C:\Program Files (x86)\Mozilla Firefox\firefox.exe
edge =
ie = iexplore.exe

; Url preferences.
Expand All @@ -28,10 +31,12 @@ Config is a poor mans INI file:
[urls]
microsoft.com = ie
*.microsoft.com = ie
google.com = chrome
visualstudio.com = edge

Notes:

- Browser paths must be exact paths to exes with no arguments (or in `PATH`). Values do not need to be quoted.
- Browser paths must be exact paths to exes with no arguments (or in `PATH`). Values do not need to be quoted. Microsoft Edge is a UWP app which cannot be started like other browsers. The path can thus remain empty.
- Only * is treated as a special character in URL patterns, and matches any characters.
- Only the domain part (or IP address) of a URL is checked.
- There is no implied wildcard at the start or end, so you must include these if you need them, but be aware that "microsoft.*" will not only match "microsoft.com" and "microsoft.co.uk" but also "microsoft.somethingelse.com".