Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Fix broken Cortana URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
da2x committed Oct 31, 2017
1 parent dfcfedb commit 78723d1
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions EdgeDeflector/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,13 @@ static bool IsMsEdgeUri(string uri)

static bool IsNonAuthoritativeWithUrlQueryParameter(string uri)
{
return uri.Contains("microsoft-edge:?") && uri.Contains("&url=");
return uri.Contains("microsoft-edge:?") && uri.Contains("&url=") && uri.Contains("bing");
}

static string GetURIFromCortanaLink(string uri)
{
NameValueCollection queryCollection = HttpUtility.ParseQueryString(uri);
return HttpUtility.UrlDecode(queryCollection["url"]);
}

static string EncodeCortanaParameters(string cortanaUri)
{
Uri uri = new Uri(cortanaUri);
return uri.AbsoluteUri + "?" + HttpUtility.UrlEncode(uri.Query);
return queryCollection["url"];
}

static string RewriteMsEdgeUriSchema(string uri)
Expand All @@ -157,10 +151,11 @@ static string RewriteMsEdgeUriSchema(string uri)
if (IsHttpUri(cortanaUri))
{
// Correctly form the new URI before returning
return EncodeCortanaParameters(cortanaUri);
return cortanaUri;
}
}

// defer fallback to web browser
return "http://" + new_uri;
}

Expand All @@ -187,6 +182,7 @@ static void Main(string[] args)
string uri = RewriteMsEdgeUriSchema(args[0]);
OpenUri(uri);
}

// Install when running without argument
else if (args.Length == 0 || args.Equals(null))
{
Expand Down

0 comments on commit 78723d1

Please sign in to comment.