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

Commit

Permalink
Fix broken things
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Nov 11, 2017
1 parent 21052c2 commit bcea4d7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
5 changes: 4 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Daniel Aleksandersen (da2x)
Mark Young (tip2tail)
Mark Young (tip2tail)

Search Engine Functionality:
RadialApps (radialapps)
1 change: 1 addition & 0 deletions EdgeDeflector/EdgeDeflector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down
38 changes: 20 additions & 18 deletions EdgeDeflector/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit bcea4d7

Please sign in to comment.