Bug 1959298 - improve SERP search params handling, r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D245040
This commit is contained in:
@@ -1650,7 +1650,7 @@ export class SearchSERPTelemetryChild extends JSWindowActorChild {
|
|||||||
* @param {object} event The event details.
|
* @param {object} event The event details.
|
||||||
*/
|
*/
|
||||||
handleEvent(event) {
|
handleEvent(event) {
|
||||||
if (!this.#urlIsSERP(this.document.documentURI)) {
|
if (!this.#urlIsSERP()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
@@ -1719,7 +1719,7 @@ export class SearchSERPTelemetryChild extends JSWindowActorChild {
|
|||||||
documentToSubmitMap.delete(this.document);
|
documentToSubmitMap.delete(this.document);
|
||||||
}
|
}
|
||||||
|
|
||||||
#urlIsSERP(url) {
|
#urlIsSERP() {
|
||||||
let provider = this._getProviderInfoForUrl(this.document.documentURI);
|
let provider = this._getProviderInfoForUrl(this.document.documentURI);
|
||||||
if (provider) {
|
if (provider) {
|
||||||
// Some URLs can match provider info but also be the provider's homepage
|
// Some URLs can match provider info but also be the provider's homepage
|
||||||
@@ -1727,7 +1727,7 @@ export class SearchSERPTelemetryChild extends JSWindowActorChild {
|
|||||||
// e.g. https://example.com/ vs. https://example.com/?foo=bar
|
// e.g. https://example.com/ vs. https://example.com/?foo=bar
|
||||||
// To check this, we look for the presence of the query parameter
|
// To check this, we look for the presence of the query parameter
|
||||||
// that contains a search term.
|
// that contains a search term.
|
||||||
let queries = new URLSearchParams(url.split("#")[0].split("?")[1]);
|
let queries = URL.fromURI(this.document.documentURIObject).searchParams;
|
||||||
for (let queryParamName of provider.queryParamNames) {
|
for (let queryParamName of provider.queryParamNames) {
|
||||||
if (queries.get(queryParamName)) {
|
if (queries.get(queryParamName)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -901,7 +901,7 @@ class TelemetryHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let queries = new URLSearchParams(url.split("#")[0].split("?")[1]);
|
let queries = new URL(url).searchParams;
|
||||||
queries.forEach((v, k) => {
|
queries.forEach((v, k) => {
|
||||||
queries.set(k.toLowerCase(), v);
|
queries.set(k.toLowerCase(), v);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user