From f8f20f3d5c6ee4bd5e7a43696effbb2278bd3f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Wed, 3 Apr 2013 14:54:03 +0200 Subject: [PATCH] Update addURLParameter to allow for a leading ?. re #40 --- base.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/base.php b/base.php index 9cd0cce..26271e8 100644 --- a/base.php +++ b/base.php @@ -175,14 +175,19 @@ function localize($phrase, $count=-1) { } function addURLParameter($urlParams, $paramName, $paramValue) { + $start = ""; + if (preg_match ("#^\?(.*)#", $urlParams, $matches)) { + $start = "?"; + $urlParams = $matches[1]; + } $params = array(); parse_str($urlParams, $params); - if (empty ($paramValue)) { + if (empty ($paramValue) && $paramValue != 0) { unset ($params[$paramName]); } else { $params[$paramName] = $paramValue; } - return http_build_query($params); + return $start . http_build_query($params); } class Link