delete
Used to delete the request URL, request/response headers, and request/response content.
Rule Syntax
pattern delete://prop1|prop2|... [filters...]
# Equivalent to:
pattern delete://prop1 delete://prop2 ... [filters...]The separator is either
|or&
| Parameters | Description | Detailed Documentation |
|---|---|---|
| pattern | Expression to match the request URL | Match Pattern Documentation |
| value | pathname: Delete the request path (excluding request parameters)pathname.index: index is the path segment index ..., -1, 0, 1, ... or the keyword last (see below for details)urlParams: Delete all request parametersurlParams.xxx: Delete the xxx parameter of the URLreqHeaders.xxx: Delete the xxx field of the request headerresHeaders.xxx: Delete the xxx field of the response headerreqBody: Delete all request contentresBody: Delete all response contentreqBody.xxx.yyy: Delete the xxx.yyy field of the request content whose type is form or JSONresBody.xxx.yyy: Delete the xxx.yyy field of the response content whose response type is JSONP or JSONreqType: Delete the type in the request header content-type, excluding the possible charsetresType: Delete the type in the response header content-type, excluding the possible charsetreqCharset: Delete the possible charset in the request header content-typeresCharset: Delete the possible charset in the response header content-typereqCookies.xxx: Delete the request header named Cookies named xxxresCookies.xxx: Deletes the cookie named xxx in the response header. | |
| filters | Optional filters, supports matching: • Request URL/Method/Header/Content • Response Status Code/Header | Filters Documentation |
Configuration Example
https://www.example.com/path delete://reqCookies.token|resCookies.token
https://raw.githubusercontent.com/avwo/whistle/refs/heads/master/package.json delete://resBody.name resType://jsonThe above cookie deletion operation only affects cookies in the request/response process and does not modify cookies stored locally in the browser. To modify browser persistent cookies, you can do so in the following ways:
- Deleting them by injecting JavaScript using jsPrepend
- Setting cookie expiration times using resCookies
Deleting Paths
Supported versions: v2.9.102 and above
Rule Syntax
# Basic Format
Target Domain delete://pathname.index
# Example
www.example.com/api/path/to delete://pathname.0 delete://pathname.1 delete://pathname.-1Rule Description
This rule deletes specific segments of the request URL's path. Whistle extracts the request path excluding query parameters, delimits it by /, and then deletes it.
Example Parsing:
- Request URL:
https://www.example.com/api/path/to/xxx?query - Extracted Path:
api/path/to/xxx - Split Array:
['api', 'path', 'to', 'xxx'] - Apply Rules:
delete://pathname.0→ Delete 'api'delete://pathname.1→ Delete 'path'delete://pathname.-1→ Delete 'xxx'
- Final Path:
/to - Complete Result:
https://www.example.com/to?query
Indexing Rules
- Positive Index: Starting at 0, indicating order from front to back
- Negative Index: Starting at -1, indicating order from back to front (-1 = last segment, -2 = second to last segment, and so on)
- Special Value: Use
lastremoves the last segment of a path but preserves the trailing slash. - Border case: Out-of-range indices are ignored.
Important Note
When a path ends with /, the split array will contain an empty string item at the end:
- Path:
/api/path/to/xxx/ - Split result:
['api', 'path', 'to', 'xxx', '']
Usage Tips
- Use
pathname.-1to remove the last segment without preserving the trailing slash. - Use
pathname.lastto remove the last segment but preserve the trailing slash.
Comparison example:
www.example.com/api/path/to delete://pathname.0 delete://pathname.1 delete://pathname.last- Request:
https://www.example.com/api/path/to/xxx?query - Result:
https://www.example.com/to/?query(preserves the trailing slash)
Special Characters
If an object key contains the following characters, it must be escaped with a backslash \ in the path expression:
- Delimiters:
|and& - Space:
(a single space) - Dot:
. - Control characters: tab
\t, newline\n, carriage return\r, form feed\f, vertical tab\v
Escape Rules
| Original Character | Escaped Form |
|---|---|
| ` | ` |
& | \& |
| Space | \ |
. | \. |
| Tab | \t |
| Newline | \n |
| Carriage Return | \r |
| Form Feed | \f |
| Vertical Tab | \v |
Note: The backslash
\itself is an escape character. To represent a literal backslash, it must be written as\\.
Example
Suppose you need to delete two keys from the request body:
- key1 is
\n .p(contains a newline, space, dot, and the letter p) - key2 is
test|&test(contains a vertical bar and an ampersand)
The corresponding path expression should be written as:
reqBody.\n\ \.p.test\|\&testWhere:
\nrepresents the newline character\represents a space\.represents a dot\|represents a vertical bar\&represents an ampersand
Complete request example:
# Delete key1 and key2 from the request body
https://www.example.com/path delete://reqBody.\n\ \.p.test\|\&test