Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Notations changes for location option

  • Loading branch information...
commit 994125e23695ec38cdcf879ae3b6bcac4ed5c68e 1 parent 420c59a
@jails jails authored
Showing with 23 additions and 1 deletion.
  1. +8 −1 net/http/Router.php
  2. +15 −0 tests/cases/net/http/RouterTest.php
View
9 net/http/Router.php
@@ -275,7 +275,14 @@ public static function match($url = array(), $context = null, array $options = a
$vars = array();
$name = $options['location'];
if(is_array($name)){
- list($name, $vars) = each($name);
+ list($tmp, $vars) = each($name);
+ if(!is_array($vars)){
+ $vars = $name;
+ $name = static::getLocation();
+ }
+ else{
+ $name = $tmp;
+ }
}
if($name && $config = static::location($name, null, $vars)) {
$config['host'] = $config['host'] ?: $defaults['host'];
View
15 tests/cases/net/http/RouterTest.php
@@ -1532,12 +1532,27 @@ public function testMatchWithLocationAndSubdomain() {
$expected = 'http://max.amiga.com/home/index';
$result = Router::match('/home/index', $request, array(
'location' => array(
+ 'subdomain' => 'max'
+ )
+ ));
+ $this->assertEqual($expected, $result);
+
+ Router::setLocation(false);
+ $result = Router::match('/home/index', $request, array(
+ 'location' => array(
'app' => array(
'subdomain' => 'max'
)
)
));
$this->assertEqual($expected, $result);
+
+ $result = Router::match('/home/index', $request, array(
+ 'location' => array(
+ 'subdomain' => 'max'
+ )
+ ));
+ $this->assertNotEqual($expected, $result);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.