Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hwlite: always use the "q" parameter for doublefetch #57

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions modules/human-web-lite/sources/url-analyzer.es
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export default class UrlAnalyzer {
const url_ = url.replace(/\+/g, '%20');
const parsedUrl = parse(url_);

// prefer the original query before spell correction
const query = parsedUrl.searchParams.get('oq') || parsedUrl.searchParams.get('q');
const query = parsedUrl.searchParams.get('q');
if (query) {
const query_ = encodeURIComponent(query).replace(/%20/g, '+');
const doublefetchUrl = `https://${parsedUrl.host}/search?q=${query_}`;
Expand Down
10 changes: 10 additions & 0 deletions modules/human-web-lite/tests/unit/url-analyzer-test.es
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ export default describeModule('human-web-lite/url-analyzer',
});
});

it('should support queries from auto-completion ("magnus ca" -> "magnus carlsen")', function () {
const url = 'https://www.google.com/search?q=magnus+carlsen&source=hp&oq=magnus+ca&gs_l=mobile-heirloom-hp.1.1.41j0i512i433i131l2j0i3l2.3398.7907.0.12670.10.8.0.2.2.0.250.1118.1j6j1.8.0....0...1c.1.34.mobile-heirloom-hp..0.10.1209.82wOg7b9tFw';
expect(uut.parseSearchLinks(url)).to.eql({
found: true,
type: 'search-go',
query: 'magnus carlsen',
doublefetchRequest: searchGoDoublefetch('https://www.google.com/search?q=magnus+carlsen'),
});
});

it('should not find term queries on non-search pages (no false-positives)', function () {
const urls = [
'https://cliqz.com/',
Expand Down