Opened on 02/16/2019 at 01:26:58 PM

Closed on 02/21/2019 at 12:47:38 PM

Last modified on 07/25/2019 at 02:14:30 PM

#7294 closed change (fixed)

Implement strip-fetch-query-parameter snippet

Reported by: mjethani Assignee: agiammarchi
Priority: P2 Milestone:
Module: Core Keywords: circumvention
Cc: sebastian Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

Description (last modified by mjethani)


In some cases we need to strip parameters from the query string of a URL while letting the request through. This is not always possible using the $rewrite option, especially with preflight OPTIONS requests, because doing so invalidates the request (307 Temporary Redirect). A snippet that wraps fetch() to strip out the given query string parameter would be handy.

What to change

Implement a snippet called strip-fetch-query-parameter with the following signature:

function stripFetchQueryParameter(name, urlPattern = null)

name should be the unencoded name of the parameter. For example, in the query string ?first%20name=John, the parameter name is first name (space).

The optional urlPattern can be a literal string or a pattern (regular expression surrounded by /) that the URL must match. If null, the snippet should work for any URL.

Hints for testers

Try the following document:

<!DOCTYPE html>
      setTimeout(() =>

The filter #$#strip-fetch-query-parameter foo example should cause the request to go to (foo is dropped). The filter #$#strip-fetch-query-parameter foo too should do the same.

The filter #$#strip-fetch-query-parameter bar other should cause the request to go to (bar is not dropped).

Attachments (0)

Change History (15)

comment:1 Changed on 02/21/2019 at 07:34:54 AM by abpbot

A commit referencing this issue has landed:
Issue 7294 - Implement strip-fetch-query-parameter snippet

comment:2 Changed on 02/21/2019 at 07:38:10 AM by mjethani

  • Owner set to agiammarchi

comment:3 Changed on 02/21/2019 at 07:38:50 AM by mjethani

  • Review URL(s) modified (diff)

comment:4 Changed on 02/21/2019 at 08:02:09 AM by mjethani

  • Description modified (diff)

comment:5 Changed on 02/21/2019 at 08:15:57 AM by mjethani

  • Review URL(s) modified (diff)

comment:6 Changed on 02/21/2019 at 08:16:13 AM by mjethani

  • Status changed from new to reviewing

comment:7 Changed on 02/21/2019 at 12:46:24 PM by abpbot

comment:8 Changed on 02/21/2019 at 12:47:38 PM by mjethani

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:9 Changed on 03/20/2019 at 04:56:31 PM by abpbot

comment:10 Changed on 03/26/2019 at 04:33:22 PM by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Implemented and working in the browsers listed below. However it does not appear to work in Chrome 49 (#7407), Edge (#7409) or Firefox Mobile (#7410).

Chrome 73.0.3683.86 / Windows 10
Firefox 65.0.1 / Windows 10
Firefox 51.0 / Windows 10
Opera 58.0.3135.118 / Windows 10

comment:11 Changed on 03/26/2019 at 04:57:57 PM by agiammarchi

Most likely 'cause they don't have fetch to start with, so that the page would throw errors regardless ?

comment:12 Changed on 03/26/2019 at 11:05:38 PM by sebastian

  • Cc sebastian added

According to MDN, all these browsers support the fetch() API.

comment:13 Changed on 03/27/2019 at 09:08:08 AM by agiammarchi

I think Manish found the issue with the URL searchParams

comment:14 Changed on 04/04/2019 at 09:42:49 AM by mjethani

  • Sensitive unset

comment:15 Changed on 07/25/2019 at 02:14:30 PM by Ross

Done. Working as described. Now works in Chrome 49/Edge/Firefox Mobile.

Microsoft Edge 44.17763.1.0 / Windows 10 1809

Chrome 49.0.2623.75 / Windows 10 1809
Chrome 75.0.3770.142 / Windows 10 1809
Opera 36.0.2130.65 / Windows 10 1809
Opera 62.0.3331.72 / Windows 10 1809
Firefox 51.0 / Windows 10 1809
Firefox 68.0 / Windows 10 1809
Firefox Mobile 68.0 / Android 7.2.2

Add Comment

Modify Ticket

Change Properties
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from agiammarchi.
Note: See TracTickets for help on using tickets.