Skip to content

Commit d8ccbed

Browse files
authored
Merge pull request #575 from favicode/fix/rate-limit-paths
Fix for rate limit paths
2 parents e11a901 + dc756b1 commit d8ccbed

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Diff for: Controller/Adminhtml/FastlyCdn/RateLimiting/ToggleRateLimiting.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ private function processPaths()
278278
$validPaths[] = 'req.url.path ~ "' . $value->path . '"';
279279
}
280280

281-
return implode(' || ', $validPaths);
281+
return !empty($validPaths)
282+
? implode(' || ', $validPaths)
283+
: 'req.url.path ~ "^/fastly-io-tester$"';
282284
}
283285

284286
/**

Diff for: Controller/Adminhtml/FastlyCdn/RateLimiting/UpdatePaths.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function execute()
114114
if (!$paths) {
115115
$paths = [];
116116
}
117-
$validPaths = '';
117+
$validPaths = [];
118118

119119
$snippet = $this->config->getVclSnippets(
120120
Config::VCL_RATE_LIMITING_PATH,
@@ -142,10 +142,12 @@ public function execute()
142142
'msg' => $value['path'] . ' is not a valid regular expression'
143143
]);
144144
}
145-
$validPaths .= 'req.url.path ~ "' . $value['path'] . '" || ';
145+
$validPaths[] = 'req.url.path ~ "' . $value['path'] . '"';
146146
}
147147

148-
$strippedValidPaths = substr($validPaths, 0, strrpos($validPaths, '||', -1));
148+
$strippedValidPaths = !empty($validPaths)
149+
? implode(' || ', $validPaths)
150+
: 'req.url.path ~ "^/fastly-io-tester$"';
149151

150152
foreach ($snippet as $key => $value) {
151153
if ($validPaths == '') {

0 commit comments

Comments
 (0)