docs/docs/rules/htmlPrepend.md
在现有响应内容体前面面插入指定内容(仅对响应类型 content-type 包含 html,且包含响应内容体的状态码(如 200/500 等)有才效)
⚠️ 注意:204、304 等无响应内容体的请求不受影响
pattern htmlPrepend://value [filters...]
| 参数 | 描述 | 详细文档 |
|---|---|---|
| pattern | 匹配请求 URL 的表达式 | 匹配模式文档 |
| value | 文本或二进制内容,支持以下类型: | |
| • 目录/文件路径 | ||
| • 远程 URL | ||
| • 内联/内嵌/Values内容 | 操作指令文档 | |
| filters | 可选过滤器,支持匹配: | |
| • 请求URL/方法/头部/内容 | ||
| • 响应状态码/头部 | 过滤器文档 |
www.example.com/path htmlPrepend://(Hello) file://(-test-)
www.example.com/path2 htmlPrepend://(Hello) file://(-test-) resType://js
https://www.example.com/path/to 响应内容变成
<!DOCTYPE html>
Hello-test-
https://www.example.com/path2/to 响应内容变成 -test-``` body.txt
Hello world.
```
www.example.com/path htmlPrepend://{body.txt} file://(-test-)
www.example.com/path2 htmlPrepend://{body.txt} file://(-test-) resType://css
https://www.example.com/path/to 响应内容变成
<!DOCTYPE html>
Hello world.-test-
https://www.example.com/path2/to 响应内容变成 -test-当接口响应类型(Content-Type)不规范地返回为 text/html 时,可能导致:
使用 enable://strictHtml 或 enable://safeHtml 模式保护非 HTML 内容:
www.example.com/path1 htmlPrepend://(test) file://(-test-) enable://strictHtml
www.example.com/path2 htmlPrepend://(test) file://([-test-]) enable://strictHtml
www.example.com/path3 htmlPrepend://(test) file://([-test-]) enable://safeHtml
www.example.com/path4 htmlPrepend://(test) file://(<div>Test</div>) enable://strictHtml
https://www.example.com/path1/to 响应内容变成 -test-https://www.example.com/path2/to 响应内容变成 [-test-]https://www.example.com/path3/to 响应内容变成 [-test-]https://www.example.com/path4/to 响应内容变成
<!DOCTYPE html>
test<div>Test</div>
safeHtml/strictHtml 功能参考:enable://safeHtml、lineProps://strictHtml
www.example.com/path1 htmlPrepend:///User/xxx/test.txt
www.example.com/path2 htmlPrepend://https://www.xxx.com/xxx/params.txt
# 通过编辑临时文件
www.example.com/path3 htmlPrepend://temp/blank.txt