-
Notifications
You must be signed in to change notification settings - Fork 150
Prefix authority with double slash if present. #235
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although having read through the interface and looking at the Guzzle implementation I agree that this patch fixes an issue. However, it does introduce a BC break (as some things may rely on this already not having //
prefixed)
public function testAuthorityIsPrefixedByDoubleSlashIfPresent() | ||
{ | ||
$uri = (new Uri())->withHost('example.com'); | ||
$this->assertEquals('//example.com', (string) $uri); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is exactly the same as testUriDoesNotAppendColonToHostIfPortIsEmpty
except the URL used... not sure we need both except for being explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unsure too.
Every bug fixed is a sort of BC break as you cannot know if there are things that relay on the old behavior, but for me it should be fixed in order to be PSR7 compliant. |
@ajgarlag why you have closed this PR? |
@sharifzadesina It was an error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree that this is bugfix that ensures that the behavior follows the documented expectations of PSR-7. That said, I'll push it to the 1.4.0 release so we can message it more clearly.
Prefix authority with double slash if present.
Merged to develop for release with 1.4.0. Thanks, @ajgarlag |
zend-diactoros 1.4.0 Added ----- - [zendframework#219](zendframework#219) adds two new classes, `Zend\Diactoros\Request\ArraySerializer` and `Zend\Diactoros\Response\ArraySerializer`. Each exposes the static methods `toArray()` and `fromArray()`, allowing de/serialization of messages from and to arrays. - [zendframework#236](zendframework#236) adds two new constants to the `Response` class: `MIN_STATUS_CODE_VALUE` and `MAX_STATUS_CODE_VALUE`. Changes ------- - [zendframework#240](zendframework#240) changes the behavior of `ServerRequestFactory::fromGlobals()` when no `$cookies` argument is present. Previously, it would use `$_COOKIES`; now, if a `Cookie` header is present, it will parse and use that to populate the instance instead. This change allows utilizing cookies that contain period characters (`.`) in their names (PHP's built-in cookie handling renames these to replace `.` with `_`, which can lead to synchronization issues with clients). - [zendframework#235](zendframework#235) changes the behavior of `Uri::__toString()` to better follow proscribed behavior in PSR-7. In particular, prior to this release, if a scheme was missing but an authority was present, the class was incorrectly returning a value that did not include a `//` prefix. As of this release, it now does this correctly. Deprecated ---------- - Nothing. Removed ------- - Nothing. Fixed ----- - Nothing.
The PSR-7 docblock of the
UriInterface::__toString
method, states that:This PR tests and fixes that behavior.