@@ -536,19 +536,7 @@ private function pathApplies(string $uri, $paths)
536
536
$ paths = [$ paths ];
537
537
}
538
538
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 );
552
540
}
553
541
554
542
/**
@@ -571,12 +559,21 @@ private function checkExcept(string $uri, $paths): bool
571
559
$ paths = [$ paths ];
572
560
}
573
561
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
575
571
foreach ($ paths as $ path ) {
576
572
// need to escape path separators
577
573
$ path = str_replace ('/ ' , '\/ ' , trim ($ path , '/ ' ));
578
574
// need to make pseudo wildcard real
579
575
$ path = strtolower (str_replace ('* ' , '.* ' , $ path ));
576
+
580
577
// Does this rule apply here?
581
578
if (preg_match ('#^ ' . $ path . '$# ' , $ uri , $ match ) === 1 ) {
582
579
return true ;
0 commit comments