Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #141 from wengh:release
Browse files Browse the repository at this point in the history
fixed bug with bing links from Settings
  • Loading branch information
spikespaz authored Jul 1, 2021
2 parents b2e6994 + eff2528 commit 7b8c61a
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions source/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -317,27 +317,26 @@ string[string] getQueryParams(const string uri) {
/// Return a tuple of the search term that was typed in (if any),
/// the URL that was typed (if any), and the URL that was selected from the search results panel (if any)
Tuple!(string, "searchTerm", string, "enteredUrl", string, "selectedUrl") getSearchInfo(const string uri) {
if (!uri.toLower().startsWith("microsoft-edge:"))
throw new Exception("Not a 'MICROSOFT-EDGE' URI: " ~ uri);
immutable string edgePrefix = "microsoft-edge:";
if (uri.toLower().startsWith(edgePrefix))
return getSearchInfo(uri[edgePrefix.length .. $]);

auto returnTuple = typeof(return)(tuple(null, null, null));
string[string] queryParams = getQueryParams(uri);

if (queryParams is null || "url" !in queryParams)
if (queryParams is null)
return returnTuple;

const string urlParam = queryParams["url"].decodeComponent();

if (urlParam.matchFirst(r"^https:\/\/.+\.bing.com")) {
queryParams = getQueryParams(urlParam);

if ("url" in queryParams && "q" in queryParams) {
returnTuple.searchTerm = queryParams["q"].decodeComponent();
returnTuple.selectedUrl = cast(string) Base64URL.decode(queryParams["url"]);
} else if ("q" in queryParams)
returnTuple.searchTerm = queryParams["q"].decodeComponent();
} else
returnTuple.enteredUrl = urlParam;
if ("url" in queryParams && "q" in queryParams) {
returnTuple.searchTerm = queryParams["q"].decodeComponent();
returnTuple.selectedUrl = cast(string) Base64URL.decode(queryParams["url"]);
} else if ("q" in queryParams) {
returnTuple.searchTerm = queryParams["q"].decodeComponent();
} else if ("url" in queryParams) {
returnTuple = getSearchInfo(queryParams["url"].decodeComponent());
} else {
returnTuple.enteredUrl = uri;
}

return returnTuple;
}
Expand Down

0 comments on commit 7b8c61a

Please sign in to comment.