Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
-- Release Notes --

Release 0.7.1.2, 21 March 2012

* The Modify action now supports replacing a header based on a regex in the value field.
Any string in the value for a Modify action which matches the form /foo/bar/ triggers the code.
foo can be a regular expression and bar is the string which replaces the match.
Example:
Action: Modify
Name: Host
Value: {^w{0,3}\.?domain.com$}{192.168.254.65}
This will change www.domain.com and domain.com to 192.168.254.65 if found in the Host header.
(Updated 28th)

--

Release 0.7.1.1, 30 November 2011

* Fixed bug 24593: Addon toolbar is displayed every time a new window is opened
Expand Down
16 changes: 14 additions & 2 deletions src/components/modifyheaders-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,20 @@ if (!ModifyHeaders.Proxy) {
// This is the default for action = Modify
var headerValue = headers[i].value;
var headerAppend = false;

if (headers[i].action == "Add") {

// Could add a new action "Regex" instead.
// For the following code to run, the value supplied by the user
// should be of the form: {foo}{bar}
// where 'foo' can be a regular expression
// and 'bar' is the string to replace the match with.
if(headers[i].action == "Modify") {
var isRegex = headerValue.match(/^\{(.*?)\}\{(.*?)\}$/);
if(isRegex.length>0) { // OR == 2 to be stricter
var currentHeaderValue = subject.getRequestHeader(headerName);
// 0 = {foo}{bar}; 1 = foo; 2 = bar;
headerValue = currentHeaderValue.replace(new RegExp(isRegex[1]), isRegex[2]);
}
} else if (headers[i].action == "Add") {
headerAppend = true;
} else if (headers[i].action == "Filter") {
headerValue = "";
Expand Down