mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
Optimisations
This commit is contained in:
@@ -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), '/'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user