This repository has been archived by the owner on Mar 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
245 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,15 +19,16 @@ | |
/** | ||
* Add a base path the URI path | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class AddBasePath implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* A HierarchicalPath object | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Add a leading slash to the URI path | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class AddLeadingSlash implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* Modify a URI part | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,10 @@ | |
/** | ||
* Add the root Label to the Host | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class AddRootLabel implements UriMiddlewareInterface | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Add a trailing slash to the URI path | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class AddTrailingSlash implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* Modify a URI part | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,10 @@ | |
/** | ||
* Append a label to the URI host | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class AppendLabel implements UriMiddlewareInterface | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,10 @@ | |
/** | ||
* Append a quey string to the URI query | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class AppendQuery implements UriMiddlewareInterface | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Append a segment to the URI path | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class AppendSegment implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* The path to append | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Path component extension modifier | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class Basename implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* The basename to use for URI modification | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,13 @@ | |
namespace League\Uri\Modifiers; | ||
|
||
/** | ||
* A class to ease applying multiple modification | ||
* on a URI object based on the pipeline pattern | ||
* This class is based on league.pipeline | ||
* An Adapter Class to convert a callable into | ||
* an UriMiddlewareInterface implementing object | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class CallableAdapter implements UriMiddlewareInterface | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Data Uri Paramaters Manipulator | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class DataUriParameters implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* The parameters to add | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Convert the Data URI to its ascii version | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class DataUriToAscii implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* Modify a URI part | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Convert the Data URI to its binary version | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class DataUriToBinary implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* Modify a URI part | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
/** | ||
* A class to Decode URI parts unreserved characters | ||
* | ||
* @package League.uri | ||
* @package League\Uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 4.2.0 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Path component extension modifier | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class Dirname implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* The dirname to use for URI modification | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,16 @@ | |
/** | ||
* Path component extension modifier | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class Extension implements UriMiddlewareInterface | ||
{ | ||
use PathMiddlewareTrait; | ||
use UriMiddlewareTrait; | ||
|
||
/** | ||
* The extension to use for URI modification | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,10 @@ | |
/** | ||
* A class to manipulate URI and URI components output | ||
* | ||
* @package League.uri | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
* @package League\Uri | ||
* @subpackage League\Uri\Modifiers | ||
* @author Ignace Nyamagana Butera <[email protected]> | ||
* @since 1.0.0 | ||
*/ | ||
class Formatter implements EncodingInterface | ||
{ | ||
|
@@ -72,10 +73,10 @@ public function setEncoding(int $enc_type) | |
static $enc_type_list; | ||
if (null === $enc_type_list) { | ||
$enc_type_list = [ | ||
EncodingInterface::RFC1738_ENCODING => 1, | ||
EncodingInterface::RFC3986_ENCODING => 1, | ||
EncodingInterface::RFC3987_ENCODING => 1, | ||
EncodingInterface::NO_ENCODING => 1, | ||
self::RFC1738_ENCODING => 1, | ||
self::RFC3986_ENCODING => 1, | ||
self::RFC3987_ENCODING => 1, | ||
self::NO_ENCODING => 1, | ||
]; | ||
} | ||
|
||
|
@@ -167,25 +168,29 @@ public function __invoke($input) | |
*/ | ||
protected function formatUri($uri): string | ||
{ | ||
$authority = null; | ||
|
||
$scheme = $uri->getScheme(); | ||
if ('' !== $scheme) { | ||
$scheme .= ':'; | ||
if ('' != $scheme) { | ||
$scheme = $scheme.':'; | ||
} | ||
|
||
$user_info = (new UserInfo())->withContent($uri->getUserInfo())->getContent($this->enc_type); | ||
if ('' !== $user_info) { | ||
$user_info .= '@'; | ||
$user_info = $uri->getUserInfo(); | ||
if ('' != $user_info) { | ||
$authority .= (new UserInfo())->withContent($user_info)->getContent($this->enc_type).'@'; | ||
} | ||
|
||
$host = (new Host($uri->getHost()))->getContent($this->enc_type); | ||
$host = $uri->getHost(); | ||
if ('' != $host) { | ||
$authority .= (new Host($host))->getContent($this->enc_type); | ||
} | ||
|
||
$port = $uri->getPort(); | ||
if ('' != $port) { | ||
$port = ':'.$port; | ||
if (null !== $port) { | ||
$authority .= ':'.$port; | ||
} | ||
|
||
$authority = $user_info.$host.$port; | ||
if ('' != $authority) { | ||
if (null !== $authority) { | ||
$authority = '//'.$authority; | ||
} | ||
|
||
|
@@ -194,14 +199,14 @@ protected function formatUri($uri): string | |
$path = '/'.$path; | ||
} | ||
|
||
$query = Query::build(Query::parse($uri->getQuery()), $this->query_separator, $this->enc_type); | ||
if ($this->preserve_query || '' != $query) { | ||
$query = '?'.$query; | ||
$query = $uri->getQuery(); | ||
if ('' != $query || $this->preserve_query) { | ||
$query = '?'.Query::build(Query::parse((string) $query), $this->query_separator, $this->enc_type); | ||
} | ||
|
||
$fragment = (new Fragment($uri->getFragment()))->getContent($this->enc_type); | ||
if ($this->preserve_fragment || '' != $fragment) { | ||
$fragment = '#'.$fragment; | ||
$fragment = $uri->getFragment(); | ||
if ('' != $fragment || $this->preserve_fragment) { | ||
$fragment = '#'.(new Fragment($fragment))->getContent($this->enc_type); | ||
} | ||
|
||
return $scheme.$authority.$path.$query.$fragment; | ||
|
Oops, something went wrong.