declare local var.imgclass STRING;
declare local var.optAllowIOParams BOOL;
declare local var.optRequireValidClass BOOL;
set var.optAllowIOParams = true;
set var.optRequireValidClass = true;
if (req.url.ext ~ "(?i)^(gif|png|jpe?g|webp)$") {
set = "fastly";
if (fastly.ff.visits_this_service == 0) {
if (!var.optAllowIOParams) {
set req.url = querystring.filter_except(req.url, "class");
}
if (subfield(req.url.qs, "class", "&")) {
set var.imgclass = table.lookup(io_classes, subfield(req.url.qs, "class", "&"));
if (std.strlen(var.imgclass) == 0) {
set var.imgclass = table.lookup(io_classes, "default");
}
if (var.imgclass) {
set req.url = req.url.path + "?" + req.url.qs + "&" + var.imgclass;
set req.url = querystring.filter(req.url, "class");
}
}
if (!var.imgclass && var.optRequireValidClass) {
error 404;
}
}
}