From cf5386de70bb04367c6e287c6d011f0fae63b685 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 23 Aug 2016 18:35:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Url.php | 3 +++ tests/thinkphp/library/think/urlTest.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/library/think/Url.php b/library/think/Url.php index c297c5b3..181b3bcf 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -236,6 +236,9 @@ class Url { foreach ($rule as $item) { list($url, $pattern, $domain) = $item; + if (empty($pattern)) { + return [$url, $domain]; + } foreach ($pattern as $key => $val) { if (isset($vars[$key])) { $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key . '', '<' . $key . '>'], $vars[$key], $url); diff --git a/tests/thinkphp/library/think/urlTest.php b/tests/thinkphp/library/think/urlTest.php index d8c748fd..73d7d1b0 100644 --- a/tests/thinkphp/library/think/urlTest.php +++ b/tests/thinkphp/library/think/urlTest.php @@ -57,7 +57,7 @@ class urlTest extends \PHPUnit_Framework_TestCase public function testBuildMethod() { Route::get('blog/:id', '\app\index\controller\blog@read'); - $this->assertEquals('/blog/10.html', Url::build('\app\index\controller\blog\read', 'id=10', 'html')); + $this->assertEquals('/blog/10.html', Url::build('[\app\index\controller\blog@read]', 'id=10', 'html')); } public function testBuildRoute() @@ -71,7 +71,7 @@ class urlTest extends \PHPUnit_Framework_TestCase public function testBuildNameRoute() { Route::get(['name', 'blog/:id'], 'index/blog'); - $this->assertEquals(['blog/:id', ['id' => 1], null], Route::name('name')); + $this->assertEquals(['blog/:id', [['id' => 1], null]], Route::name('name')); Config::set('url_html_suffix', 'shtml'); $this->assertEquals('/blog/10.shtml', Url::build('name?id=10')); }