Skip to content
Browse files

Fixed url suffix position in site_url() result string if argument $ur…

…i contains query string.

Used http_build_query() function for building query string instead of array iteration.
  • Loading branch information...
1 parent 0c4fb6a commit 626efa13a133a881dce4fe040b3be144f2fa896e @Dumk0 committed
Showing with 13 additions and 12 deletions.
  1. +13 −12 system/core/Config.php
View
25 system/core/Config.php
@@ -245,8 +245,7 @@ public function site_url($uri = '')
if ($this->item('enable_query_strings') == FALSE)
{
- $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
- return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
+ return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri);
}
else
{
@@ -284,19 +283,21 @@ protected function _uri_string($uri)
{
$uri = implode('/', $uri);
}
- return trim($uri, '/');
+ $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
+ if (strpos($uri, '?') === FALSE)
+ {
+ return trim($uri, '/').$suffix;
+ }
+ else
+ {
+ // There is a query string in uri, add suffix before parameters
+ list($uri_seg, $uri_qry) = explode('?', $uri);
+ return trim($uri_seg, '/').$suffix.'?'.$uri_qry;
+ }
}
elseif (is_array($uri))
{
- $i = 0;
- $str = '';
- foreach ($uri as $key => $val)
- {
- $prefix = ($i === 0) ? '' : '&';
- $str .= $prefix.$key.'='.$val;
- $i++;
- }
- return $str;
+ return http_build_query($uri);
}
return $uri;

0 comments on commit 626efa1

Please sign in to comment.
Something went wrong with that request. Please try again.