mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-15 18:23:26 +03:00
@@ -50,12 +50,12 @@ class BaseCsrfVerifier implements IMiddleware
|
||||
$url = rtrim($url, '*');
|
||||
$skip = $request->getUrl()->contains($url);
|
||||
} else {
|
||||
$skip = ($url === $request->getUrl()->getOriginalUrl());
|
||||
$skip = ($url === rtrim($request->getUrl()->getRelativeUrl(false), '/'));
|
||||
}
|
||||
|
||||
if ($skip === true) {
|
||||
|
||||
if($this->include !== null && count($this->include) > 0) {
|
||||
if(is_array($this->include) === true && count($this->include) > 0) {
|
||||
foreach($this->include as $includeUrl) {
|
||||
$includeUrl = rtrim($includeUrl, '/');
|
||||
if ($includeUrl[strlen($includeUrl) - 1] === '*') {
|
||||
@@ -64,7 +64,7 @@ class BaseCsrfVerifier implements IMiddleware
|
||||
break;
|
||||
}
|
||||
|
||||
$skip = !($includeUrl === $request->getUrl()->getOriginalUrl());
|
||||
$skip = !($includeUrl === rtrim($request->getUrl()->getRelativeUrl(false), '/'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ abstract class IpRestrictAccess implements IMiddleware
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @throws HttpException
|
||||
*/
|
||||
public function handle(Request $request): void
|
||||
{
|
||||
if($this->validate((string)$request->getIp()) === false) {
|
||||
|
||||
@@ -427,14 +427,18 @@ class Url implements JsonSerializable
|
||||
/**
|
||||
* Returns the relative url
|
||||
*
|
||||
* @param bool $includeParams
|
||||
* @return string
|
||||
*/
|
||||
public function getRelativeUrl(): string
|
||||
public function getRelativeUrl($includeParams = true): string
|
||||
{
|
||||
$params = $this->getQueryString();
|
||||
$path = $this->path ?? '/';
|
||||
|
||||
$path = $this->path ?? '';
|
||||
$query = $params !== '' ? '?' . $params : '';
|
||||
if($includeParams === false) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
$query = $this->getQueryString() !== '' ? '?' . $this->getQueryString() : '';
|
||||
$fragment = $this->fragment !== null ? '#' . $this->fragment : '';
|
||||
|
||||
return $path . $query . $fragment;
|
||||
@@ -443,9 +447,10 @@ class Url implements JsonSerializable
|
||||
/**
|
||||
* Returns the absolute url
|
||||
*
|
||||
* @param bool $includeParams
|
||||
* @return string
|
||||
*/
|
||||
public function getAbsoluteUrl(): string
|
||||
public function getAbsoluteUrl($includeParams = true): string
|
||||
{
|
||||
$scheme = $this->scheme !== null ? $this->scheme . '://' : '';
|
||||
$host = $this->host ?? '';
|
||||
@@ -454,7 +459,7 @@ class Url implements JsonSerializable
|
||||
$pass = $this->password !== null ? ':' . $this->password : '';
|
||||
$pass = ($user || $pass) ? $pass . '@' : '';
|
||||
|
||||
return $scheme . $user . $pass . $host . $port . $this->getRelativeUrl();
|
||||
return $scheme . $user . $pass . $host . $port . $this->getRelativeUrl($includeParams);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -183,7 +183,6 @@ class RouteGroup extends Route implements IGroupRoute
|
||||
*/
|
||||
public function setSettings(array $settings, bool $merge = false): IRoute
|
||||
{
|
||||
|
||||
if (isset($settings['prefix']) === true) {
|
||||
$this->setPrefix($settings['prefix'] . $this->prefix);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Router helper class
|
||||
* ---------------------------
|
||||
*
|
||||
* This class is added so calls can be made statically like Router::get() making the code look pretty.
|
||||
* It also adds some extra functionality like default-namespace.
|
||||
* This class is added so calls can be made statically like SimpleRouter::get() making the code look pretty.
|
||||
* It also adds some extra functionality like default-namespace etc.
|
||||
*/
|
||||
|
||||
namespace Pecee\SimpleRouter;
|
||||
|
||||
Reference in New Issue
Block a user