Skip to content

Commit ec0eea1

Browse files
author
glebv
committed
Add rewrite method
1 parent 392e9cd commit ec0eea1

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,14 @@ Full API
402402
* Hosts to remap
403403
* CALLBACK(ERROR) function
404404
1. ERROR string if there was an error
405+
406+
**rewrite(PORT, REWRITE_OBJ, CALLBACK)**
407+
408+
Redirecting URL's for proxy on PORT
409+
410+
PARAMETERS:
411+
412+
* PORT of proxy for this command
413+
* REWRITE_OBJ an object with 2 mandatory keys: matchRegex and replace. Any set keys will be set on the specified proxy port
414+
* CALLBACK(ERROR) function
415+
1. ERROR string if there was an error

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,18 @@ Proxy.prototype = {
208208
this.doReqWithOptions(options, postData, cb);
209209
},
210210

211+
/*
212+
* matchRegex - A matching URL regular expression
213+
* replace - Replacement URL
214+
*/
215+
rewrite: function(port, obj, cb) {
216+
var data = '';
217+
for (key in obj) {
218+
data += key + '=' + obj[key] + '&';
219+
}
220+
this.doReq("PUT", "/proxy/" + port + "/rewrite", data, cb);
221+
},
222+
211223
doReq: function (method, url, postData, cb) {
212224
var options = {
213225
host: this.host, port: this.port, method: method, path: url, headers: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "browsermob-proxy",
33
"description": "Javascript bindings for the browsermob-proxy",
44
"keywords": ["selenium", "test", "testing", "proxy", "tests", "har"],
5-
"version": "1.0.9",
5+
"version": "1.0.10",
66
"author": "Mark Ethan Trostler <mark@zzo.com>",
77
"repository": {
88
"type": "git",

0 commit comments

Comments
 (0)