Skip to content

Commit c37cb9b

Browse files
authored
fix bugs
1 parent d1a215c commit c37cb9b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

App/Core.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,21 @@ public function setParams($params)
7777
}
7878

7979
// Match the route item against the request method and URI
80-
8180
public function match($request_method, $request_uri)
8281
{
83-
$request_uri = rtrim($request_uri, '/');
84-
if ($this->method === $request_method && preg_match($this->pathRegex[$this->path], $request_uri, $matches)) {
82+
$parsed_url = parse_url($request_uri);
83+
$request_path = $parsed_url['path'];
84+
85+
$request_path = rtrim($request_path, '/');
86+
if ($this->method === $request_method && preg_match($this->pathRegex[$this->path], $request_path, $matches)) {
8587
$this->params = array_slice($matches, 1);
8688
return true;
8789
}
90+
8891
return false;
8992
}
9093

9194
// Execute the controller method associated with this route item
92-
9395
public function execute()
9496
{
9597
if (is_callable($this->controller)) {

0 commit comments

Comments
 (0)