docs/en/docs/rules/delete.md
Used to delete the request URL, request/response headers, and request/response content.
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 parameters | ||
urlParams.xxx: Delete the xxx parameter of the URL | ||
reqHeaders.xxx: Delete the xxx field of the request header | ||
resHeaders.xxx: Delete the xxx field of the response header | ||
reqBody: Delete all request content | ||
resBody: Delete all response content | ||
reqBody.xxx.yyy: Delete the xxx.yyy field of the request content whose type is form or JSON | ||
resBody.xxx.yyy: Delete the xxx.yyy field of the response content whose response type is JSONP or JSON | ||
reqType: Delete the type in the request header content-type, excluding the possible charset | ||
resType: Delete the type in the response header content-type, excluding the possible charset | ||
reqCharset: Delete the possible charset in the request header content-type | ||
resCharset: Delete the possible charset in the response header content-type | ||
reqCookies.xxx: Delete the request header named Cookies named xxx | ||
resCookies.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 |
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://json
The 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:
Supported versions: v2.9.102 and above
# Basic Format
Target Domain delete://pathname.index
# Example
www.example.com/api/path/to delete://pathname.0 delete://pathname.1 delete://pathname.-1
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:
https://www.example.com/api/path/to/xxx?queryapi/path/to/xxx['api', 'path', 'to', 'xxx']delete://pathname.0 → Delete 'api'delete://pathname.1 → Delete 'path'delete://pathname.-1 → Delete 'xxx'/tohttps://www.example.com/to?querylast removes the last segment of a path but preserves the trailing slash.When a path ends with /, the split array will contain an empty string item at the end:
/api/path/to/xxx/['api', 'path', 'to', 'xxx', '']pathname.-1 to remove the last segment without preserving the trailing slash.pathname.last to 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
https://www.example.com/api/path/to/xxx?queryhttps://www.example.com/to/?query (preserves the trailing slash)If an object key contains the following characters, it must be escaped with a backslash \ in the path expression:
| and & (a single space).\t, newline \n, carriage return \r, form feed \f, vertical tab \v| 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\\.
Suppose you need to delete two keys from the request body:
\n .p (contains a newline, space, dot, and the letter p)test|&test (contains a vertical bar and an ampersand)The corresponding path expression should be written as:
reqBody.\n\ \.p.test\|\&test
Where:
\n represents the newline character\ represents a space\. represents a dot\| represents a vertical bar\& represents an ampersandComplete request example:
# Delete key1 and key2 from the request body
https://www.example.com/path delete://reqBody.\n\ \.p.test\|\&test