Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow https on scheme without a hostname #3997

Closed
wants to merge 2 commits into from

3 participants

@Danielss89

No description provided.

@DASPRiD
Collaborator

Waiting for unit test as discussed on IRC.

@DASPRiD
Collaborator

Looks good now.

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3997'
Close #3997
0f26e36
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3997' into develop
Forward port #3997
f8c50fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 9, 2013
  1. @Danielss89
Commits on Mar 10, 2013
  1. @Danielss89

    Added unittest

    Danielss89 authored
This page is out of date. Refresh to see the latest.
View
14 library/Zend/Mvc/Router/Http/TreeRouteStack.php
@@ -225,12 +225,16 @@ public function assemble(array $params = array(), array $options = array())
$uri->setFragment($options['fragment']);
}
- if ((isset($options['force_canonical']) && $options['force_canonical']) || $uri->getHost() !== null) {
- if ($uri->getScheme() === null) {
- if ($this->requestUri === null) {
- throw new Exception\RuntimeException('Request URI has not been set');
- }
+ if ((isset($options['force_canonical']) && $options['force_canonical']) || $uri->getHost() !== null || $uri->getScheme() !== null) {
+ if (($uri->getHost() === null || $uri->getScheme() === null) && $this->requestUri === null) {
+ throw new Exception\RuntimeException('Request URI has not been set');
+ }
+
+ if ($uri->getHost() === null) {
+ $uri->setHost($this->requestUri->getHost());
+ }
+ if ($uri->getScheme() === null) {
$uri->setScheme($this->requestUri->getScheme());
}
View
27 tests/ZendTest/Mvc/Router/Http/TreeRouteStackTest.php
@@ -228,6 +228,33 @@ public function testAssembleWithQueryParams()
$this->assertEquals('/?foo=bar', $stack->assemble(array(), array('name' => 'index', 'query' => array('foo' => 'bar'))));
}
+ public function testAssembleWithScheme()
+ {
+ $uri = new HttpUri();
+ $uri->setScheme('http');
+ $uri->setHost('example.com');
+ $stack = new TreeRouteStack();
+ $stack->setRequestUri($uri);
+ $stack->addRoute(
+ 'secure',
+ array(
+ 'type' => 'Scheme',
+ 'options' => array(
+ 'scheme' => 'https'
+ ),
+ 'child_routes' => array(
+ 'index' => array(
+ 'type' => 'Literal',
+ 'options' => array(
+ 'route' => '/',
+ ),
+ ),
+ ),
+ )
+ );
+ $this->assertEquals('https://example.com/', $stack->assemble(array(), array('name' => 'secure/index')));
+ }
+
public function testAssembleWithFragment()
{
$stack = new TreeRouteStack();
Something went wrong with that request. Please try again.