You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What if my path contains not ASCII characters?
Probably, the URI class must have public methods encode and decode?
Moreover, the PSR-7 almost directly talking about it:
Users can provide both encoded and decoded path characters.
That is, if the user wants to decode the string - there are decoding method.
If we need to encode a string (eg, target) - there is an encoding method.
I think that something like this:
public static function encode($value, $ignore = null)
{
if (null === $ignore) {
$ignore = static::CHAR_UNRESERVED
. static::CHAR_GEN_DELIMS
. static::CHAR_SUB_DELIMS;
}
$rawurlencode = function (array $matches) {
return rawurlencode($matches[0]);
};
return preg_replace_callback(
'/(?:[^' . $ignore . '%]+|%(?![A-Fa-f0-9]{2}))/',
$rawurlencode,
$value
);
}
/**
* Decode URI-encoded strings.
*
* @param string $value The encoded string
*
* @return string The decoded string
*/
public static function decode($value)
{
return rawurldecode($value);
}
Or even easier
protected function setTarget($target)
{
if ('*' == $target) {
$this->target = $target;
return $this;
}
$uri = new Uri($target);
$this->target = (string) $uri;
return $this;
}
::getRequestTarget()
http://tools.ietf.org/html/rfc7230#section-5.3.1
The query component is optional, the path is required.
But in code if exists only query - return it
probably it would be correct:
Originally posted by @easy-system at zendframework/zend-diactoros#153
The text was updated successfully, but these errors were encountered: