summaryrefslogtreecommitdiffstats
path: root/system/helpers/url_helper.php
diff options
context:
space:
mode:
authorAaron Adams <aaron@aaronadams.ca>2012-12-08 04:39:23 +0100
committerAaron Adams <aaron@aaronadams.ca>2012-12-08 04:39:23 +0100
commit16800e4e356fa1aa3d92d368e6e495b97b64ad83 (patch)
tree3ad3f05eea022a3369328d95a1a92c533f2ac1c6 /system/helpers/url_helper.php
parent5c54f18e5728e6793f8917b917da2e6866fb1ffb (diff)
While most of CodeIgniter supports protocol-relative URLs, a few URL helpers do not.
Most notably, redirect('//www.facebook.com/aaronadams') led my browser to https://aaronadams.ca/index.php/www.facebook.com/aaronadams. In this commit, I have fixed the header() helper, along with the anchor() and anchor_popup() helpers, to be compatible with protocol-relative URLs. Signed-off-by: Aaron Adams <aaron@aaronadams.ca>
Diffstat (limited to 'system/helpers/url_helper.php')
-rw-r--r--system/helpers/url_helper.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 14c216afe..36ff0ff2c 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -152,7 +152,7 @@ if ( ! function_exists('anchor'))
if ( ! is_array($uri))
{
- $site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri);
+ $site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
}
else
{
@@ -191,7 +191,7 @@ if ( ! function_exists('anchor_popup'))
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
$title = (string) $title;
- $site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri);
+ $site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
if ($title === '')
{
@@ -535,7 +535,7 @@ if ( ! function_exists('redirect'))
*/
function redirect($uri = '', $method = 'auto', $code = NULL)
{
- if ( ! preg_match('#^https?://#i', $uri))
+ if ( ! preg_match('#^(\w+:)?//#i', $uri))
{
$uri = site_url($uri);
}