Skip to content
Snippets Groups Projects

Issue #3167426: CurrentPathStack::getPath should always return a path with leading slashes

5 files
+ 66
3
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -2,6 +2,7 @@
namespace Drupal\Core\Path;
use Drupal\Core\Routing\RequestContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -46,14 +47,14 @@ public function __construct(RequestStack $request_stack) {
* (optional) The request.
*
* @return string
* Returns the path, without leading slashes.
* Returns the un-decoded path, with leading slashes.
*/
public function getPath(?Request $request = NULL) {
if (!isset($request)) {
$request = $this->requestStack->getCurrentRequest();
}
if (!isset($this->paths[$request])) {
$this->paths[$request] = $request->getPathInfo();
$this->paths[$request] = RequestContext::prependSlash($request->getPathInfo());
}
return $this->paths[$request];
@@ -73,7 +74,7 @@ public function setPath($path, ?Request $request = NULL) {
if (!isset($request)) {
$request = $this->requestStack->getCurrentRequest();
}
$this->paths[$request] = $path;
$this->paths[$request] = RequestContext::prependSlash($path);
return $this;
}
Loading