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

View File

@@ -50,7 +50,7 @@ class BaseCsrfVerifier implements IMiddleware
$url = rtrim($url, '*');
$skip = $request->getUrl()->contains($url);
} else {
$skip = ($url === $request->getUrl()->getRelativeUrl(false));
$skip = ($url === rtrim($request->getUrl()->getRelativeUrl(false), '/'));
}
if ($skip === true) {
@@ -64,7 +64,7 @@ class BaseCsrfVerifier implements IMiddleware
break;
}
$skip = !($includeUrl === $request->getUrl()->getRelativeUrl(false));
$skip = !($includeUrl === rtrim($request->getUrl()->getRelativeUrl(false), '/'));
}
}

View File

@@ -432,14 +432,13 @@ class Url implements JsonSerializable
*/
public function getRelativeUrl($includeParams = true): string
{
$path = $this->path ?? '/';
if($includeParams === false) {
return rtrim($this->path, '/');
return $path;
}
$params = $this->getQueryString();
$path = $this->path ?? '';
$query = $params !== '' ? '?' . $params : '';
$query = $this->getQueryString() !== '' ? '?' . $this->getQueryString() : '';
$fragment = $this->fragment !== null ? '#' . $this->fragment : '';
return $path . $query . $fragment;