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

Commit

Permalink
Match with regex in uri rewrite (fixes #32)
Browse files Browse the repository at this point in the history
  • Loading branch information
spikespaz committed Oct 6, 2018
1 parent 6d0788b commit b892d2f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/deflector.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import std.string: replace, indexOf, toLower, startsWith;
import std.windows.registry: Registry, Key, REGSAM;
import std.uri: decodeComponent, encodeComponent;
import common: createErrorDialog;
import std.regex: matchFirst;
import std.array: split;
import std.conv: to;

Expand All @@ -29,7 +30,7 @@ string rewriteUri(const string uri, const string engineUrl) {
if (queryParams !is null && "url" in queryParams) {
const string url = queryParams["url"].decodeComponent();

if (url.startsWith("https://www.bing.com"))
if (url.matchFirst(`^https:\/\/.+\.bing.com`))
return "https://" ~ engineUrl.replace("{{query}}", getQueryParams(url)["q"]);
else
return url;
Expand Down

0 comments on commit b892d2f

Please sign in to comment.