From 90b2fd011e03e3d0cb103c8a83ca82dcbae391d3 Mon Sep 17 00:00:00 2001 From: Fabrice Luraine Date: Thu, 5 Aug 2010 12:01:36 +0200 Subject: [PATCH] Fixing bug when using a 0 in paths passed to url_for [#44 state:resolved] --- lib/limonade.php | 2 +- tests/main.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/limonade.php b/lib/limonade.php index 3d9a73f..8f546d6 100644 --- a/lib/limonade.php +++ b/lib/limonade.php @@ -1598,7 +1598,7 @@ function url_for($params = null) $p = explode('/',$param); foreach($p as $v) { - if(!empty($v)) $paths[] = str_replace('%23', '#', rawurlencode($v)); + if($v != "") $paths[] = str_replace('%23', '#', rawurlencode($v)); } } diff --git a/tests/main.php b/tests/main.php index a92833f..8de5b70 100644 --- a/tests/main.php +++ b/tests/main.php @@ -182,6 +182,9 @@ function test_main_url_for() assert_equal(url_for('mañana'), '/'.rawurlencode("mañana")); assert_equal(url_for('test', 1, 2), '/test/1/2'); assert_equal(url_for('one', 'two', 'three'), '/one/two/three'); + assert_equal(url_for('one', 0, 'three'), '/one/0/three'); + assert_equal(url_for('one', '', 'three'), '/one/three'); + assert_equal(url_for('one', null, 'three'), '/one/three'); assert_equal(url_for('my/hash#test'), '/my/hash#test'); $site_url = 'http://www.limonade-php.net'; assert_true((bool) filter_var_url($site_url));