Skip to content

Commit f73b854

Browse files
Merge pull request #67 from nextcloud/refactor/simplify-ocs-check
2 parents d60f991 + e7cb49c commit f73b854

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

generate-spec

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,13 @@ if (count($parsedRoutes) == 0) {
235235

236236
$routes = [];
237237
foreach ($parsedRoutes as $key => $value) {
238-
if ($key != "routes" && $key != "ocs") {
238+
$isOCS = $key === "ocs";
239+
$isIndex = $key === "routes";
240+
241+
if (!$isOCS && !$isIndex) {
239242
continue;
240243
}
244+
241245
foreach ($value as $route) {
242246
$routeName = $route["name"];
243247

@@ -253,10 +257,10 @@ foreach ($parsedRoutes as $key => $value) {
253257
if (str_ends_with($url, "/")) {
254258
$url = substr($url, 0, -1);
255259
}
256-
if ($key == "routes") {
260+
if ($isIndex) {
257261
$url = "/index.php" . $root . $url;
258262
}
259-
if ($key == "ocs") {
263+
if ($isOCS) {
260264
$url = "/ocs/v2.php" . $root . $url;
261265
}
262266

@@ -320,7 +324,6 @@ foreach ($parsedRoutes as $key => $value) {
320324
}
321325

322326
$isCSRFRequired = !Helpers::classMethodHasAnnotationOrAttribute($methodFunction, "NoCSRFRequired");
323-
$isOCS = $controllerClass->extends != "Controller" && $controllerClass->extends != "ApiController";
324327
if ($isCSRFRequired && !$isOCS) {
325328
Logger::debug($routeName, "Route ignored because of required CSRF in a non-OCS controller");
326329
continue;

0 commit comments

Comments
 (0)