private function stripRouteFromPath(RequestInterface $request, $route) { $this->removed = $route; $uri = $request->getUri(); $path = $this->getTruncatedPath($route, $uri->getPath()); $new = $uri->withPath($path); // Root path of route is treated differently if ($path === '/' && '/' === substr($uri->getPath(), -1)) { $this->removed .= '/'; } return $request->withUri($new); }