Optimisations

This commit is contained in:
Simon Sessingø
2021-04-01 03:11:05 +02:00
parent 52c6c226c0
commit b94dc4355f
2 changed files with 6 additions and 7 deletions
@@ -50,7 +50,7 @@ class BaseCsrfVerifier implements IMiddleware
$url = rtrim($url, '*'); $url = rtrim($url, '*');
$skip = $request->getUrl()->contains($url); $skip = $request->getUrl()->contains($url);
} else { } else {
$skip = ($url === $request->getUrl()->getRelativeUrl(false)); $skip = ($url === rtrim($request->getUrl()->getRelativeUrl(false), '/'));
} }
if ($skip === true) { if ($skip === true) {
@@ -64,7 +64,7 @@ class BaseCsrfVerifier implements IMiddleware
break; break;
} }
$skip = !($includeUrl === $request->getUrl()->getRelativeUrl(false)); $skip = !($includeUrl === rtrim($request->getUrl()->getRelativeUrl(false), '/'));
} }
} }
+4 -5
View File
@@ -432,14 +432,13 @@ class Url implements JsonSerializable
*/ */
public function getRelativeUrl($includeParams = true): string public function getRelativeUrl($includeParams = true): string
{ {
$path = $this->path ?? '/';
if($includeParams === false) { if($includeParams === false) {
return rtrim($this->path, '/'); return $path;
} }
$params = $this->getQueryString(); $query = $this->getQueryString() !== '' ? '?' . $this->getQueryString() : '';
$path = $this->path ?? '';
$query = $params !== '' ? '?' . $params : '';
$fragment = $this->fragment !== null ? '#' . $this->fragment : ''; $fragment = $this->fragment !== null ? '#' . $this->fragment : '';
return $path . $query . $fragment; return $path . $query . $fragment;