Skip to content

Commit b6a3c7d

Browse files
committed
refactor: extract method
1 parent fc3ae4c commit b6a3c7d

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

system/Filters/Filters.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -536,19 +536,7 @@ private function pathApplies(string $uri, $paths)
536536
$paths = [$paths];
537537
}
538538

539-
// treat each paths as pseudo-regex
540-
foreach ($paths as $path) {
541-
// need to escape path separators
542-
$path = str_replace('/', '\/', trim($path, '/ '));
543-
// need to make pseudo wildcard real
544-
$path = strtolower(str_replace('*', '.*', $path));
545-
// Does this rule apply here?
546-
if (preg_match('#^' . $path . '$#', $uri, $match) === 1) {
547-
return true;
548-
}
549-
}
550-
551-
return false;
539+
return $this->checkPseudoRegex($uri, $paths);
552540
}
553541

554542
/**
@@ -571,12 +559,21 @@ private function checkExcept(string $uri, $paths): bool
571559
$paths = [$paths];
572560
}
573561

574-
// treat each paths as pseudo-regex
562+
return $this->checkPseudoRegex($uri, $paths);
563+
}
564+
565+
/**
566+
* Check the URI path as pseudo-regex
567+
*/
568+
private function checkPseudoRegex(string $uri, array $paths): bool
569+
{
570+
// treat each path as pseudo-regex
575571
foreach ($paths as $path) {
576572
// need to escape path separators
577573
$path = str_replace('/', '\/', trim($path, '/ '));
578574
// need to make pseudo wildcard real
579575
$path = strtolower(str_replace('*', '.*', $path));
576+
580577
// Does this rule apply here?
581578
if (preg_match('#^' . $path . '$#', $uri, $match) === 1) {
582579
return true;

0 commit comments

Comments
 (0)