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:
sessingo
2023-03-25 02:20:06 +01:00
parent 5ab5087f8e
commit 74c52931e9
8 changed files with 140 additions and 36 deletions
+18 -2
View File
@@ -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;
}