Skip to content

Commit

Permalink
While most of CodeIgniter supports protocol-relative URLs, a few URL …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
aaronadamsCA committed Dec 8, 2012
1 parent 5c54f18 commit 16800e4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions system/helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function anchor($uri = '', $title = '', $attributes = '')

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
{
Expand Down Expand Up @@ -191,7 +191,7 @@ function anchor($uri = '', $title = '', $attributes = '')
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 === '')
{
Expand Down Expand Up @@ -535,7 +535,7 @@ function url_title($str, $separator = '-', $lowercase = FALSE)
*/
function redirect($uri = '', $method = 'auto', $code = NULL)
{
if ( ! preg_match('#^https?://#i', $uri))
if ( ! preg_match('#^(\w+:)?//#i', $uri))
{
$uri = site_url($uri);
}
Expand Down

0 comments on commit 16800e4

Please sign in to comment.