Skip to content

Commit

Permalink
refactor: urlReplace -> pathReplace
Browse files Browse the repository at this point in the history
  • Loading branch information
avwo committed Sep 1, 2018
1 parent 2272c7a commit 29d5256
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/zh/rules/pathReplace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# pathReplace

类似js字符串的replace方法,利用正则或字符串来匹配替换请求url的path部分(如`http://www.test.com/xxx?xxx`,只能替换url中`xxx?xxx`这部分的内容),配置方式:

pattern pathReplace://filepath

filepath为[Values](http://local.whistlejs.com/#values)里面的{key}或者本地文件(如:`e:\test\xxx``e:/test/xxx``/User/username/test/xxx`等):

/user=([^&])/ig: user=$1$1
str: replacement

pattern参见[匹配模式](../pattern.html),更多模式请参考[配置方式](../mode.html),json格式参考[操作值](../data.html)

例子:

www.ifeng.com pathReplace://{test-resReplace.json}


test-pathReplace.json:

/user=([^&])/ig: user=$1$1
index: news

0 comments on commit 29d5256

Please sign in to comment.