resReplace
Replaces the response body content using a method similar to JavaScript's String.replace() (only valid for requests with a response body, such as 200 and 500). Supports multiple text formats:
- JSON (
application/json) - XML (
application/xml) - HTML (
text/html) - Plain text (
text/xxx)
Rule Syntax
txt
pattern resReplace://value [filters...]| Parameters | Description | Detailed Documentation |
|---|---|---|
| pattern | Expression to match against the request URL | Match Pattern Documentation |
| value | Replacement configuration object, supported from the following sources: • Directory/file path • Remote URL • Inline/embedded/Values content | Operation Instruction Documentation |
| filters | Optional filters, supporting matching: • Request URL/Method/Header/Content • Response Status Code/Header | Filter Documentation |
Configuration Example
Inline Mode
txt
www.example.com/path file://(00user-11test-22user-33test) resReplace://user=abc&/\d+/g=numberRequest https://www.example.com/path/to, browser receives:
txt
numberabc-numbertest-numberabc-numbertestInline Mode
txt
``` resReplace.json
user: name
/\d+/g: num
```
# or (note the escape character)
``` resReplace.json
{
'user': 'name',
'/\\d+/g': 'num'
}
```
www.example.com/path file://(00user-11test-22user-33test) resReplace://{resReplace.json}Request https://www.example.com/path/to Content received by the browser:
txt
numname-numtest-numname-numtestLocal/Remote Resources
txt
www.example.com/path1 resReplace:///User/xxx/test.json
www.example.com/path2 resReplace://https://www.xxx.com/xxx/params.json
# Editing a temporary file
www.example.com/path3 resReplace://temp/blank.jsonAssociated Protocols
- Inject content before the response content (
Prepend To Body): resPrepend - Inject HTML content before the response content (
Prepend HTML To Body, response type must betext/html): htmlPrepend - Inject CSS content before the response content (
Prepend CSS To Body, response type must betext/htmlortext/css): cssPrepend - Inject JS content before the response content (
Prepend JS To Body, response type must betext/html,text/css, orapplication/javascript): jsPrepend - Replace the response content (
Replace Body): resBody - Replace the response content with HTML content (
Replace Body, response type must betext/html): htmlBody - Replace the response content with CSS content (
Replace Body, response type must betext/htmlortext/css): cssBody - Replace the response content with JS content (
Replace Body, response type must betext/html,text/css, orapplication/javascript): jsBody - Append content after the response content (
Append To Body): resAppend - Append HTML content after the response content (
Append HTML To Body, response type must betext/html): htmlAppend - Append CSS content after the response content (
Append CSS To Body, response type must betext/htmlortext/css): cssAppend - Append JS content after the response content (
Append JS To Body, response type must betext/html,text/css, orapplication/javascript): jsAppend - Replace the response content using keywords or regular expressions (
Modify Body Text): resReplace - Override JSON/Form objects in the response content (
Modify Form/JSON): resMerge - Delete a property from a JSON/Form object in the response content (
Delete Form/JSON): delete://resBody.xxx