Skip to content

Commit 4b86769

Browse files
committed
🔨 improve current_url() helper function to use query_strings
Signed-off-by: otengkwame <[email protected]>
1 parent 401fabb commit 4b86769

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

CodeIgniter/Framework/helpers/url_helper.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,21 @@ function base_url($uri = '', $protocol = null)
100100
*
101101
* @return string
102102
*/
103-
function current_url()
103+
function current_url($with_query_strings = false)
104104
{
105105
$CI =& get_instance();
106-
return $CI->config->site_url($CI->uri->uri_string());
106+
107+
$url = $CI->config->site_url($CI->uri->uri_string());
108+
109+
if (
110+
$with_query_strings
111+
&& !empty($_SERVER['QUERY_STRING'])
112+
&& (config_item('allow_get_array') !== false)
113+
) {
114+
$url .= '?' . $_SERVER['QUERY_STRING'];
115+
}
116+
117+
return $url;
107118
}
108119
}
109120

0 commit comments

Comments
 (0)