This commit is contained in:
xl
2023-06-12 17:58:07 +08:00
parent f1bbc7c25c
commit 56a94564ab
+4 -2
View File
@@ -154,7 +154,9 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
public function register(string $path, string $method, Handler $handler): void public function register(string $path, string $method, Handler $handler): void
{ {
$hashMap = HashMap::Tree($this->methods, $method); $hashMap = HashMap::Tree($this->methods, $method);
foreach (str_split($path, 4) as $item) {
$lists = explode('/', $path);
foreach ($lists as $item) {
if ($hashMap->has($item)) { if ($hashMap->has($item)) {
$hashMap = $hashMap->get($item); $hashMap = $hashMap->get($item);
} else { } else {
@@ -220,7 +222,7 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
$path = '/*'; $path = '/*';
} }
$lists = str_split($path, 4); $lists = explode('/', $path);
foreach ($lists as $item) { foreach ($lists as $item) {
$parent = $parent->get($item); $parent = $parent->get($item);
if ($parent === null) { if ($parent === null) {