Unverified Commit b9b90ae6 authored by chrisgarrity's avatar chrisgarrity Committed by GitHub

Merge pull request #2403 from chrisgarrity/issue/2399-fix-fastly

Revised ?tip_bar= fastly rules
parents 8d88ab9b 84884beb
......@@ -171,6 +171,52 @@ async.auto({
if (err) return cb(err);
cb(null, headers);
});
}],
tipbarRedirectHeaders: ['version', function (cb, results) {
async.auto({
requestCondition: function (cb2) {
var condition = {
name: 'routes/?tip_bar= (request)',
statement: 'req.url ~ "\\?tip_bar="',
type: 'REQUEST',
priority: 10
};
fastly.setCondition(results.version, condition, cb2);
},
responseCondition: function (cb2) {
var condition = {
name: 'routes/?tip_bar= (response)',
statement: 'req.url ~ "\\?tip_bar="',
type: 'RESPONSE',
priority: 10
};
fastly.setCondition(results.version, condition, cb2);
},
responseObject: ['requestCondition', function (cb2, redirectResults) {
var responseObject = {
name: 'redirects/?tip_bar=',
status: 301,
response: 'Moved Permanently',
request_condition: redirectResults.requestCondition.name
};
fastly.setResponseObject(results.version, responseObject, cb2);
}],
redirectHeader: ['responseCondition', function (cb2, redirectResults) {
var header = {
name: 'redirects/?tip_bar=',
action: 'set',
ignore_if_set: 0,
type: 'RESPONSE',
dst: 'http.Location',
src: 'regsub(req.url, "tip_bar=", "tutorial=")',
response_condition: redirectResults.responseCondition.name
};
fastly.setFastlyHeader(results.version, header, cb2);
}]
}, function (err, redirectResults) {
if (err) return cb(err);
cb(null, redirectResults);
});
}]
}, function (err, results) {
if (err) throw new Error(err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment