From bcea4d7608b3035c9d53bb0270a7f5122eddf1d5 Mon Sep 17 00:00:00 2001 From: RadialApps Date: Sat, 11 Nov 2017 15:22:04 +0530 Subject: [PATCH] Fix broken things --- AUTHORS | 5 +++- EdgeDeflector/EdgeDeflector.csproj | 1 + EdgeDeflector/Program.cs | 38 ++++++++++++++++-------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/AUTHORS b/AUTHORS index 306bd7f..7d51b24 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,2 +1,5 @@ Daniel Aleksandersen (da2x) -Mark Young (tip2tail) \ No newline at end of file +Mark Young (tip2tail) + +Search Engine Functionality: +RadialApps (radialapps) \ No newline at end of file diff --git a/EdgeDeflector/EdgeDeflector.csproj b/EdgeDeflector/EdgeDeflector.csproj index 935d31d..7f1afbe 100644 --- a/EdgeDeflector/EdgeDeflector.csproj +++ b/EdgeDeflector/EdgeDeflector.csproj @@ -61,6 +61,7 @@ + diff --git a/EdgeDeflector/Program.cs b/EdgeDeflector/Program.cs index 12f71c1..8936c9a 100644 --- a/EdgeDeflector/Program.cs +++ b/EdgeDeflector/Program.cs @@ -164,24 +164,9 @@ static string RewriteMsEdgeUriSchema(string uri) Regex rgx = new Regex(msedge_protocol_pattern); string new_uri = rgx.Replace(uri, string.Empty); - if (engine == "Google") - { - int index = new_uri.IndexOf("&"); - if (index > 0) - new_uri = new_uri.Substring(0, index); - new_uri = new_uri.Replace("bing.com/search?q=", "google.com/search?q="); - } - else if (engine == "DuckDuckGo") - { - int index = new_uri.IndexOf("&"); - if (index > 0) - new_uri = new_uri.Substring(0, index); - new_uri = new_uri.Replace("bing.com/search?q=", "duckduckgo.com/?q="); - } - if (IsHttpUri(new_uri)) { - return new_uri; + return replaceSearchEngine(new_uri, engine); } // May be new-style Cortana URI - try and split out @@ -191,12 +176,29 @@ static string RewriteMsEdgeUriSchema(string uri) if (IsHttpUri(cortanaUri)) { // Correctly form the new URI before returning - return cortanaUri; + return replaceSearchEngine(cortanaUri, engine); } } // defer fallback to web browser - return "http://" + new_uri; + return "http://" + replaceSearchEngine(new_uri, engine); + } + + static string replaceSearchEngine(string new_uri, string engine) + { + int index = new_uri.IndexOf("&"); + if (index > 0) new_uri = new_uri.Substring(0, index); + + if (engine == "Google") + { + return new_uri.Replace("bing.com/search?q=", "google.com/search?q="); + } + else if (engine == "DuckDuckGo") + { + return new_uri.Replace("bing.com/search?q=", "duckduckgo.com/?q="); + } + + return new_uri; } static void OpenUri(string uri)