Skip to content

Commit

Permalink
extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 9, 2020
1 parent 3d58cd9 commit ac6f3a8
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/Illuminate/Routing/CompiledRouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,10 @@ public function refreshActionLookups()
*/
public function match(Request $request)
{
$trimmedRequest = clone $request;

$trimmedRequest->server->set(
'REQUEST_URI', rtrim($request->server->get('REQUEST_URI'), '/')
);

$matcher = new CompiledUrlMatcher(
$this->compiled, (new RequestContext)->fromRequest($trimmedRequest)
$this->compiled, (new RequestContext)->fromRequest(
$trimmedRequest = $this->requestWithoutTrailingSlash($request)
)
);

$route = null;
Expand Down Expand Up @@ -148,6 +144,23 @@ public function match(Request $request)
return $this->handleMatchedRoute($request, $route);
}

/**
* Get a cloned instance of the given request without any trailing slash on the URI.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Request
*/
protected function requestWithoutTrailingSlash(Request $request)
{
$trimmedRequest = clone $request;

$trimmedRequest->server->set(
'REQUEST_URI', rtrim($request->server->get('REQUEST_URI'), '/')
);

return $trimmedRequest;
}

/**
* Get routes from the collection by method.
*
Expand Down

0 comments on commit ac6f3a8

Please sign in to comment.