mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
Ending trail/slash feature
- Feature: added support for slash in parameters (see readme). - Route: Fixed hardcoded param modifier. - Route: optimisations. - Updated Readme.
This commit is contained in:
+18
-2
@@ -42,6 +42,12 @@ class Url implements JsonSerializable
|
||||
*/
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* Original path with no sanitization to ending slash
|
||||
* @var string|null
|
||||
*/
|
||||
private $originalPath;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -73,6 +79,7 @@ class Url implements JsonSerializable
|
||||
|
||||
if (isset($data['path']) === true) {
|
||||
$this->setPath($data['path']);
|
||||
$this->originalPath = $data['path'];
|
||||
}
|
||||
|
||||
$this->fragment = $data['fragment'] ?? null;
|
||||
@@ -226,6 +233,15 @@ class Url implements JsonSerializable
|
||||
return $this->path ?? '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get original path with no sanitization of ending trail/slash.
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOriginalPath(): ?string
|
||||
{
|
||||
return $this->originalPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the url path
|
||||
*
|
||||
@@ -284,7 +300,7 @@ class Url implements JsonSerializable
|
||||
$params = [];
|
||||
parse_str($queryString, $params);
|
||||
|
||||
if(count($params) > 0) {
|
||||
if (count($params) > 0) {
|
||||
return $this->setParams($params);
|
||||
}
|
||||
|
||||
@@ -469,7 +485,7 @@ class Url implements JsonSerializable
|
||||
{
|
||||
$path = $this->path ?? '/';
|
||||
|
||||
if($includeParams === false) {
|
||||
if ($includeParams === false) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user