mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-18 01:07:51 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0634ba79dc | |||
| 3534233a76 | |||
| 0f55480156 | |||
| 99ed44eb1e | |||
| 565a926bd3 | |||
| 64483652ff | |||
| d17ee96221 |
@@ -98,7 +98,7 @@ class BaseCsrfVerifier implements IMiddleware
|
||||
*/
|
||||
public function handle(Request $request): void
|
||||
{
|
||||
if ($this->skip($request) === false && ($request->isPostBack() === true || $this->isIncluded($request) === true)) {
|
||||
if ($this->skip($request) === false && ($request->isPostBack() === true || $request->isPostBack() === true && $this->isIncluded($request) === true)) {
|
||||
|
||||
$token = $request->getInputHandler()->value(
|
||||
static::POST_KEY,
|
||||
|
||||
@@ -395,10 +395,6 @@ class Request
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
if ($this->url->getHost() === null && $this->getHost() !== null) {
|
||||
$this->url->setHost((string)$this->getHost());
|
||||
}
|
||||
|
||||
if ($this->isSecure() === true) {
|
||||
$this->url->setScheme('https');
|
||||
}
|
||||
@@ -409,6 +405,11 @@ class Request
|
||||
*/
|
||||
public function setHost(?string $host): void
|
||||
{
|
||||
// Strip any potential ports from hostname
|
||||
if (strpos((string)$host, ':') !== false) {
|
||||
$host = strstr($host, strrchr($host, ':'), true);
|
||||
}
|
||||
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
|
||||
+10
-4
@@ -72,7 +72,7 @@ class Url implements JsonSerializable
|
||||
|
||||
public function parse(?string $url, bool $setOriginalPath = false): self
|
||||
{
|
||||
if ($url !== null && $url !== '/') {
|
||||
if ($url !== null) {
|
||||
$data = $this->parseUrl($url);
|
||||
|
||||
$this->scheme = $data['scheme'] ?? null;
|
||||
@@ -95,6 +95,7 @@ class Url implements JsonSerializable
|
||||
$this->setQueryString($data['query']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -144,10 +145,15 @@ class Url implements JsonSerializable
|
||||
/**
|
||||
* Get url host
|
||||
*
|
||||
* @param bool $includeTrails Prepend // in front of hostname
|
||||
* @return string|null
|
||||
*/
|
||||
public function getHost(): ?string
|
||||
public function getHost(bool $includeTrails = false): ?string
|
||||
{
|
||||
if ((string)$this->host !== '' && $includeTrails === true) {
|
||||
return '//' . $this->host;
|
||||
}
|
||||
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
@@ -530,12 +536,12 @@ class Url implements JsonSerializable
|
||||
*/
|
||||
public function jsonSerialize(): string
|
||||
{
|
||||
return $this->getRelativeUrl();
|
||||
return $this->getHost(true) . $this->getRelativeUrl();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getRelativeUrl();
|
||||
return $this->getHost(true) . $this->getRelativeUrl();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -562,7 +562,6 @@ class Router
|
||||
|
||||
if ($this->request->getRewriteRoute() !== null) {
|
||||
$this->processedRoutes[] = $this->request->getRewriteRoute();
|
||||
$this->request->setHasPendingRewrite(false);
|
||||
}
|
||||
|
||||
return $this->routeRequest();
|
||||
|
||||
Reference in New Issue
Block a user